This Gist was automatically created by Carbide, a free online programming environment.
Last active
September 21, 2016 22:13
-
-
Save peterschussheim/808a31189ead73040c450c10ed4cfa7c to your computer and use it in GitHub Desktop.
createFunctions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createFunctions(n) { | |
var callbacks = []; | |
var factory = function(x) { | |
return function() { | |
return x; | |
}; | |
}; | |
callbacks.forEach(function(cb) { | |
callbacks.push(factory(i)); | |
}); | |
return callbacks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment