behave

setTimeout还是setInterval?

倾然丶 夕夏残阳落幕 提交于 2020-04-28 03:56:20
问题: 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