Last active
August 5, 2021 21:36
-
-
Save uzbekdev1/ebb5e7a109b029c131d347658bebcc0f to your computer and use it in GitHub Desktop.
JavaScript sleep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleep = (milliseconds) => { | |
return new Promise(resolve => setTimeout(resolve, milliseconds)) | |
} | |
async testWaiter(){ | |
await sleep(1000); | |
console.log('Wait a 1 second'); | |
} | |
sleep(1000).then(()=>{ | |
console.log('Wait a 1 second'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment