Created
May 22, 2011 10:41
-
-
Save voituk/985350 to your computer and use it in GitHub Desktop.
JavaScript Test 1
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
/** | |
* What you get in console after this script execution? | |
*/ | |
for (var i=0; i<5; i++ ) { | |
setTimeout(function() { | |
console.log(i) | |
}, i*1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for (var i=0; i<5; i++ ) {
(function (i) {
setTimeout(function() {
console.log(i)
}, i*1000)
})(i)
}