Skip to content

Instantly share code, notes, and snippets.

@simme
Forked from ptte/callback_scoping.js
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simme/10091806 to your computer and use it in GitHub Desktop.
Save simme/10091806 to your computer and use it in GitHub Desktop.
function test() {
for (var i=0;i < 5;i++) {
console.log('orig: '+ i);
setTimeout((function (x) {
return function () {
console.log('cb: '+ x);
}
}(i)), 100);
}
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment