Created
February 2, 2017 07:00
-
-
Save MarcusHurney/f70d9cd1ee7d57a4936bc6ea05529f6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 buildFunction() { | |
var arr = []; | |
for (var i = 0; i < 3; i++) { | |
arr.push( | |
(function(j) { | |
return function() { | |
console.log(j); | |
} | |
})(i) | |
); | |
} | |
return arr; | |
} | |
var mynew = buildFunction(); | |
mynew[0](); | |
mynew[1](); | |
mynew[2](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment