setTimeout and setInterval

Run code once after a delay, or repeatedly at an interval.

Also called: setTimeout, setInterval, clearTimeout

Domain
Languages
Source
General
Language
JavaScript

Example

setTimeout hides the "Saved" message after three seconds.

In code

const t = setTimeout(() => toast.hidden = true, 3000);
clearTimeout(t);
const poll = setInterval(checkStatus, 10000);

Learn more

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30