Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krasnobaev/edc6c618e54bc30d94737e8f3945c9bd to your computer and use it in GitHub Desktop.
Save krasnobaev/edc6c618e54bc30d94737e8f3945c9bd to your computer and use it in GitHub Desktop.
js issues
function FunctionArray(count) {
var arr = [];
for (var i = 0; i < count; i++) {
var t = {};
t.i = JSON.parse(JSON.stringify(i));
arr[i] = function () {
debugger;
alert(t.i);
}.bind(t);
}
return arr;
}
FunctionArray(100)[1]();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment