sleep
sleep
returns a Promise
that resolves after a specified number of
milliseconds.
console.log("Program starts");
await sleep(2000); // Pauses the execution for 2000 milliseconds
console.log("Program resumes after 2 seconds");
sleep
returns a Promise
that resolves after a specified number of
milliseconds.
console.log("Program starts");
await sleep(2000); // Pauses the execution for 2000 milliseconds
console.log("Program resumes after 2 seconds");