Skip to content

Instantly share code, notes, and snippets.

@joepie91

joepie91/fix.js Secret

Created February 1, 2015 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/d97a9339445719ea2f41 to your computer and use it in GitHub Desktop.
Save joepie91/d97a9339445719ea2f41 to your computer and use it in GitHub Desktop.
JavaScript asynchronous loop reference issues
for(var i in filenames) {
(function(i) {
tasks.push(function(callback) {
console.log(filenames[i]);
callback();
});
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment