Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1

The clearTimeout() method of the Window interface cancels a timeout previously established by calling Window.setTimeout().

1
12
1
4
18
1
worker_support

Available in workers

3
12
3.5
4
18
5
worker_support

Available in workers

3
12
3.5
4
18
5
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
setTimeout(code)
setTimeout(code, delay)

setTimeout(func)
setTimeout(func, delay)
setTimeout(func, delay, param1)
setTimeout(func, delay, param1, param2)
setTimeout(func, delay, param1, param2, /* …, */ paramN)

Use cases

  • Using setTimeout()

    The setTimeout() method of the Window interface sets a timer which executes a function or specified piece of code once the timer expires.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.