The usage of unref() and ref() is very simple, which is used to cancel and reply to setTimeout and setInterval functions.
The code is as follows:
The code copy is as follows:
var testFunction=function(){
console.log("guoyansi");
}
var timer=setInterval(testFunction,1000);
timer.unref();//Cancel the use of setTimeout and setInterval functions
timer.ref();//Restore the use of setTimeout and setInterval functions
Is it super simple? If you don't understand, please let go of javascript~