Skip to content

Instantly share code, notes, and snippets.

@voituk
Created May 22, 2011 10:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voituk/985350 to your computer and use it in GitHub Desktop.
Save voituk/985350 to your computer and use it in GitHub Desktop.
JavaScript Test 1
/**
* What you get in console after this script execution?
*/
for (var i=0; i<5; i++ ) {
setTimeout(function() {
console.log(i)
}, i*1000)
}
@anllemonone
Copy link

for (var i=0; i<5; i++ ) {
(function (i) {
setTimeout(function() {
console.log(i)
}, i*1000)
})(i)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment