问题:
As far as I can tell, these two pieces of javascript behave the same way: 据我所知,这两个javascript的行为方式相同:
Option A: 选项A:
function myTimeoutFunction()
{
doStuff();
setTimeout(myTimeoutFunction, 1000);
}
myTimeoutFunction();
Option B: 选项B:
function myTimeoutFunction()
{
doStuff();
}
myTimeoutFunction();
setInterval(myTimeoutFunction, 1000);
Is there any difference between using setTimeout and setInterval ? 使用setTimeout和setInterval有什么区别吗?
解决方案:
参考一: https://stackoom.com/question/33sv/setTimeout还是setInterval参考二: https://oldbug.net/q/33sv/setTimeout-or-setInterval
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4333208