offline version v3


144 of 264 menu

clearTimeout function

The clearTimeout function stops the timer set by the setTimeout function. The function takes the id of the timer to stop. The timer ID is returned by the setTimeout method.

Syntax

clearTimeout(identifier);

Example

Stop the timer when the counter reaches the value 10:

let i = 0; let id = setInterval(function() { i++; if (i == 10) { clearTimeout(id); } else { console.log(i); } }, 1000);

See also

enru