Home > Web Front-end > JS Tutorial > body text

Usage examples of unref() and ref() for setTimeout and setInterval in javascript_javascript tips

WBOY
Release: 2016-05-16 16:30:24
Original
2063 people have browsed it

The usage of unref() and ref() is very simple, they are to cancel and reply to the calls of setTimeout and setInterval functions.

The code is as follows:

Copy code The code is as follows:

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

Isn’t it super simple? If you still don’t understand, please let go of javascript~

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template