clearTimeout() Function

The clearTimeout() function cancels an existing one-shot timer created by setTimeout().

Syntax

clearTimeout(timer)

Parameters

Return value

None (undefined).

Example

> timer = setTimeout(() => console.log("hello world"), 100);
undefined
hello world
> timer2 = setTimeout(() => console.log("hello world"), 2000);
undefined
> clearInterval(timer2)
undefined

References