Skip to content

Instantly share code, notes, and snippets.

@iam-peekay
Created April 29, 2016 04:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iam-peekay/942e83362855c9c26111213258bb0d6c to your computer and use it in GitHub Desktop.
Save iam-peekay/942e83362855c9c26111213258bb0d6c to your computer and use it in GitHub Desktop.
var result = [];
for (let i = 0; i < 5; i++) {
result[i] = function () {
console.log(i);
};
}
result[0](); // 0, expected 0
result[1](); // 1, expected 1
result[2](); // 2, expected 2
result[3](); // 3, expected 3
result[4](); // 4, expected 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment