Skip to content

Instantly share code, notes, and snippets.

@ashleycoker
Last active November 6, 2018 20:12
Show Gist options
  • Save ashleycoker/45cd461b41d4da5d9e6d73832e75c1b0 to your computer and use it in GitHub Desktop.
Save ashleycoker/45cd461b41d4da5d9e6d73832e75c1b0 to your computer and use it in GitHub Desktop.
var f = function(){
maxCount=5;
for (var i=0 ;i<maxCount; i++){
alert(i);
}
}
function createOperations(){
var operations = [];
for (var i = 0; i < 5; i++) {
operations.push(function(input){
return input * i;
})
}
return operations;
}
var ops = createOperations();
for (var i = 0; i < 5; i++) {
alert(ops[i](i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment