Repeating setTimeout

前端 未结 7 869
太阳男子
太阳男子 2020-12-15 15:56

I am trying to repeat setTimeout every 10 seconds. I know that setTimeout by default only waits and then performs an action one time. How can I rep

7条回答
  •  暖寄归人
    2020-12-15 16:30

    Here is a function using setTimeout that tried to call itself as close as it can to a regular interval. If you watch the output, you can see the time drifting and being reset.

    
    
    
    

提交回复
热议问题