Last active
March 23, 2017 18:33
-
-
Save edysegura/2c8d0af2223a9c7df74b232259aa1631 to your computer and use it in GitHub Desktop.
[JS] Sleep function in JavaScript
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
function sleep(milliSeconds) { | |
let startTime = Date.now(); | |
while(Date.now() < startTime + milliSeconds); | |
} | |
//it will hold the thread in 10 seconds | |
sleep(10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment