Created
October 11, 2016 14:56
-
-
Save kzsh/2b556335f1d6114b03670e3a4d27ae5e to your computer and use it in GitHub Desktop.
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
const a = { | |
a: function() { | |
console.log(a.a); | |
}, | |
}; | |
const b = { | |
b() { | |
console.log(b.b) | |
} | |
}; | |
const c = function() { | |
console.log(c) | |
} | |
a.a(); | |
b.b(); | |
c(); | |
// -------------------------------------------------------------------------------------------------------- | |
function gen(name) { | |
const c = { | |
[name]: function () { | |
console.log(c[name]); | |
} | |
}; | |
return c; | |
} | |
const result = gen('test'); | |
console.log('test'); | |
result['test'](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment