Favorites

DOM Window.clearTimeout() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Window.clearTimeout()
DOM Window MethodThis method is supported by all modern browsers.
Updated 28th November 2026

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

<input id="search" placeholder="Search...">
const search = document.getElementById('search');
let timer;
search.addEventListener('input', () => {
  clearTimeout(timer);
  timer = setTimeout(() => console.log('Search for:', search.value), 400);
});
console.log('Type quickly: the search only runs after you pause');

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.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee