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

前端 未结 5 1469
滥情空心
滥情空心 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 you can call clearTimeout on a nullvariable.

    Also i would suggest you change your setTimeout so it won't use eval:

    timer = setTimeout(onAir,60000);
    

提交回复
热议问题