[removed] Is it ok to call cleartimeout before settimeout?

前端 未结 5 1472
滥情空心
滥情空心 2021-02-18 19:05

I have a function that sets a timer, and calls itself back upon expiration of the timer.

What I\'d like to know is if it is bad practice to clear the timer at the top o

5条回答
  •  不知归路
    2021-02-18 19:46

    Yes, that's fine. Also, you should call "setTimeout()" like this:

      timer = setTimeout(onAir, 60000);
    

提交回复
热议问题