The question is: does setInterval wait for the end of the receiveComent function or does it call it every 500ml?
setInterval(receiveComent, 500)
The question is: does setInterval wait for the end of the receiveComent function or does it call it every 500ml?
setInterval(receiveComent, 500)
setInterval does not wait for the completion of the previous function call. If there is a danger of delaying the called function (for example, a long polling of the remote server), it is better to act based on setTimeout
(function loop(){ setTimeout(function(){ // Здесь логика // ... // Рекурсивный вызов loop(); }, 1000); })();
It calls whenever possible every 500ms.
Source: https://ru.stackoverflow.com/questions/82977/
All Articles