Created
February 1, 2015 06:30
-
-
Save IOExceptional/e7c77984bdadf808688f to your computer and use it in GitHub Desktop.
Asynchronous JavaScript is a lie!
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
<html> | |
<head> | |
<title>JsTestBed</title> | |
</head> | |
<body> | |
<h2>"Async" test</h2> | |
<p> | |
In JavaScript, asynchronous calls are a lie!<br /> | |
What actually happens is the setTimeout(func, 0); gets put on the end of the call list.<br /> | |
Any direct javascript functions will get prioritised and run before the function in the timeout. | |
</p> | |
<script> | |
var i = 0; | |
setTimeout(function () { | |
alert(i); | |
}, 0); | |
for(var x = 50000; i < x; i++){ | |
console.log("pain"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment