Recursive setTimeout in javascript

前端 未结 2 742
长情又很酷
长情又很酷 2021-01-20 11:11

Is it possible to run this \"indefinitely\", without causing stack overflow or running out of memory?

function eternal(){
    var time = recalculateTime();
          


        
2条回答
  •  孤街浪徒
    2021-01-20 11:37

    That should be fine. Once setTimeout runs it will return from the eternal function before it's calls it again.

提交回复
热议问题