I have an application using JavaScript's setInterval()
to run a digital clock. I was wondering if it has a timeout, or limit, to the amount of times it can execute this function.
setInterval()
will run infinitely.
If you wish to terminate the 'loop' you can use clearInterval. For example:
var counter = 0;
var looper = setInterval(function(){
counter++;
console.log("Counter is: " + counter);
if (counter >= 5)
{
clearInterval(looper);
}
}, 1000);