Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

The cleanest JavaScript sleep() function

node v4.9.1
version: master
endpointsharetweet
Implementing sleep(milliseconds) with async/await
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } console.log('Taking a break...'); await sleep(2000); console.log('Two seconds later'); // Click the ⟳ icon to the right =========>
Loading…

no comments

    sign in to comment