Unref of and ref of usage examples for setTimeout and setInterval in javascript

  • 2020-03-30 04:22:21
  • OfStack

The usage of unref() and ref() is very simple, which is to cancel and reply to setTimeout and setInterval function.

The code is as follows:


 var testFunction=function(){
     console.log("guoyansi");
 }
 var timer=setInterval(testFunction,1000);
 timer.unref();//Cancel the setTimeout and setInterval function with
 timer.ref();//Restore the setTimeout and setInterval function with

Is not super simple, if you do not understand, please let go of javascript ~


Related articles: