Created
October 1, 2020 07:54
-
-
Save mvictorl/6fedb1d17980f9a4162184a899de7098 to your computer and use it in GitHub Desktop.
JS function sleep() vice setTimeout() [return Promise]
This file contains 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 = ms => { | |
return new Promise(resolve => { | |
setTimeout(() => resolve(), ms) | |
}) | |
} | |
sleep(3000).then(() => console.log('After 3 seconds...')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment