I have a problem understanding the way in which setInterval and clearInterval work in JavaScript.
I have read different articles on these two functions but I am still confused.
Given the fact that JavaScript is single thread then when we call test=setInterval(function(){}, t) we will schedule our function to be executed every t miliseconds. Unless we clearInterval(test).
- What does that mean? Does it mean that by
clearIntervalwecanclethesetIntervalwhich is already in the queue of JavaScript? - What would happen if we
setIntervalseveral times butclearIntervalonly once? - Can we
clearIntervalinsetInterval? - How JavaScript handles the scheduled process?