setTimeout or setInterval?

前端 未结 19 3631
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 04:59

As far as I can tell, these two pieces of javascript behave the same way:

Option A:

function myTimeoutFunction()
{
    doStuff();
           


        
19条回答
  •  清歌不尽
    2020-11-21 05:47

    I use setTimeout.

    Apparently the difference is setTimeout calls the method once, setInterval calls it repeatdly.

    Here is a good article explaining the difference: Tutorial: JavaScript timers with setTimeout and setInterval

提交回复
热议问题