setInterval() behaviour with 0 milliseconds in JavaScript

前端 未结 4 978
孤独总比滥情好
孤独总比滥情好 2020-11-27 21:18

In my application I found some JavaScript code that is using setInterval with 0 milliseconds, like so:

self.setInterval(\"myFunction()\",0);
         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 21:31

    setInterval(myFunction, 0) calls myFunction continuously with minimum delay. It is almost like calling myFunction in a infinite loop. Except that here you can stop the loop using the clearInterval method.

提交回复
热议问题