Skip to content

Instantly share code, notes, and snippets.

@gu-stav
Forked from gtrufitt/settimeout.js
Last active March 16, 2017 15:17
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 gu-stav/b5087d8dabab6c61c6dcf3469dc00d75 to your computer and use it in GitHub Desktop.
Save gu-stav/b5087d8dabab6c61c6dcf3469dc00d75 to your computer and use it in GitHub Desktop.
Test setTimouet
console.log('first script start');
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu until time's up
}
sleep(2000)
console.log('first script end');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment