Last active
August 29, 2015 14:25
-
-
Save ewilazarus/1c7053e63465354577c7 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 buildFunctions() { | |
var arr = []; | |
for (var i = 0; i < 3; i++) { | |
arr.push((function(j) { | |
return function() { | |
console.log(j); | |
}; | |
}(i))); | |
} | |
return arr; | |
} | |
var fs = buildFunctions(); | |
fs[0](); | |
fs[1](); | |
fs[2](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment