clearTimeout() global function

Cancel the timer set by setTimeout.

Syntax

  clearTimeout(timerId: number): void;

Parameter

timerId

The timer ID returned by setTimeout. If the timer corresponding to this ID has already finished executing, the method will not perform any action.

** Passing in an ID value that is not returned by setTimeout is undefined behavior and may cause problems. **

Example

Notes

  1. setTimeout() and setInterval() have a shared pool of ID numbers, so technically clearTimeout() and clearInterval() are interchangeable. However, for clarity, you should avoid doing so.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.