Menu

gitpiper

sleep javascript Code Snippet in 2024

functionpromiseintermediate

Last Updated: 2 October 2024

Delays the execution of an asynchronous function.

  • Delay executing part of an async function, by putting it to sleep, returning a new Promise().
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
async function sleepyWork() { console.log("I'm going to sleep for 1 second."); await sleep(1000); console.log('I woke up after 1 second.'); }

javascript snippet similar to sleep For You in October 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️