Skip to content

Instantly share code, notes, and snippets.

@mneedham
Created March 10, 2010 18:53
Show Gist options
  • Select an option

  • Save mneedham/328201 to your computer and use it in GitHub Desktop.

Select an option

Save mneedham/328201 to your computer and use it in GitHub Desktop.
function getValues() {
var x = new Array();
for(var i=0; i < 10; ++i) {
x[i] = function() { return i; }
}
return x;
};
var values = getValues();
console.log(values)
for(var j=0; j < values.length; ++j) {
console.log(values[j]());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment