Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

clearInterval

  • clearInterval

  • setInterval

  • setTimeout

  • setInterval returns an identifier that can later be used to stop the scheduled process.

  • clearInterval will stop a scheduled process.

var intervalId = setInterval(function() {
    console.log("world");
}, 1000);

setTimeout(function() {
    console.log("Calling clearInterval");
    clearInterval(intervalId);
}, 3030);

console.log("hello");
$ node examples/basic/with_clearinterval.js
hello
world
world
world
Calling clearInterval