Created
October 22, 2013 05:28
-
-
Save lcaballero/7095626 to your computer and use it in GitHub Desktop.
Example showing the event loop halting because of a `while` loop.
This file contains hidden or 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
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