setTimeout()
noun
say it: “set TIME-owt” /sɛt ˈtaɪmaʊt/
A JavaScript function that runs another function once, after waiting at least the number of milliseconds you give it.
What is setTimeout() in JavaScript?
setTimeout() — Schedules a function to run once, after a delay in milliseconds (1000 is one second), and returns a timer ID that clearTimeout() can cancel it with. Pass the function itself, with no () after its name.
setTimeout(() => {
console.log('Order #42 is ready'); // printed after 2 seconds
}, 2000);
In a sentence
- “The game shows the next question with setTimeout(), 1,500 milliseconds after the player answers.”
- “I used setTimeout() to hide the "Saved!" message two seconds after it appeared.”
Level: Apprentice · More JavaScript terms at this level
Updated