Created
January 30, 2015 20:30
-
-
Save soltys/7b45bccf39e183c84a33 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/besaziwibe
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
var o = {}; | |
var animals = ["cat", "dog", "fan"]; | |
for(var i=0; i < 3; i++){ | |
var animalName = animals[i]; | |
var funName = animalName + "Fun"; | |
o[funName] = function(){ | |
return animalName; | |
}; | |
} | |
console.log(o); | |
console.log(o.dogFun()); | |
console.log(o.catFun()); | |
console.log(o.fanFun()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment