To delay in JavaScript, use the
setTimeout
function.Here's how you do it:
console.log('This is logged immediately');
setTimeout(() => {
console.log('This is logged after a second');
}, 1000);
setTimeout
function.Here's how you do it:
console.log('This is logged immediately');
setTimeout(() => {
console.log('This is logged after a second');
}, 1000);