Using setTimeout and setInterval for Timing Operations in Javascript


Schedule code execution using timers.

Source Code

setTimeout(() => console.log('Executes after 2 seconds'), 2000);
let intervalId = setInterval(() => console.log('Executes every 3 seconds'), 3000);
// To clear the interval
clearInterval(intervalId);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments