๐ซSetTimeout
console.log('Starting countdown...');
// This function will be executed after 2 seconds
setTimeout(function() {
console.log('2 seconds elapsed');
}, 2000);
console.log('Countdown started');const timer = setTimeout(function() {
console.log('This timer will not be executed');
}, 2000);
// This cancels the timer
clearTimeout(timer);Last updated