DOM Window.clearTimeout() Method
The clearTimeout() method cancels a timer set with setTimeout() before it runs.
Description
The clearTimeout() method cancels a timeout created with setTimeout(), if it hasn't run yet. Passing an invalid or already-finished ID does nothing. A common use is debouncing: restarting a timer each time an event fires, so the work only happens once things settle down.
It's good practice to clear pending timeouts when they're no longer needed, such as when a component is removed from the page or a dialog closes, so callbacks don't run against elements that no longer exist.
The IDs returned by setTimeout() and setInterval() come from the same pool, so clearTimeout() and clearInterval() can technically cancel either, but using the matching function keeps code clear.
Syntax
clearTimeout(timeoutID)Parameters
- timeoutIDThe ID returned by
setTimeout().
Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the Window.clearTimeout() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





