A couple years ago I was warned against using setInterval
for long periods of time as it supposedly would cause the browser to hang if the called function ran longer than the designated interval, and would then not be able to catch up:
setInterval( function(){
foo = 'bar_' + i++;
}, 1 );
Now, I'm aware that adding lots of code in a loop could cause the browser to hang anyway, and that blocking code like alert
, prompt
, and confirm
will stop the code in it's tracks, but is there any good reason to avoid setInterval
?
Note: I am aware of how to do recursive setTimeout
calls (as that's what I've been using), this question is my trying to figure out if it's still worth using them, or whether setInterval
can be used safely.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…