Skip to content

Instantly share code, notes, and snippets.

@edysegura
Last active March 23, 2017 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edysegura/2c8d0af2223a9c7df74b232259aa1631 to your computer and use it in GitHub Desktop.
Save edysegura/2c8d0af2223a9c7df74b232259aa1631 to your computer and use it in GitHub Desktop.
[JS] Sleep function in JavaScript
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