Skip to content

Instantly share code, notes, and snippets.

@lcaballero
Created October 22, 2013 05:28
Show Gist options
  • Save lcaballero/7095626 to your computer and use it in GitHub Desktop.
Save lcaballero/7095626 to your computer and use it in GitHub Desktop.
Example showing the event loop halting because of a `while` loop.
setTimeout(function() {
console.log("after 2sec")
}, 2000)
d = new Date()
while (new Date().getTime() - d.getTime() < 3000);
console.log("after 3sec")
// Output:
// after 3sec
// after 2sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment