Skip to content

Instantly share code, notes, and snippets.

@kzsh
Created October 11, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzsh/2b556335f1d6114b03670e3a4d27ae5e to your computer and use it in GitHub Desktop.
Save kzsh/2b556335f1d6114b03670e3a4d27ae5e to your computer and use it in GitHub Desktop.
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