-
-
Save brigand/f07822cdb368fe8bdd49 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 KEY = Symbol('my key') | |
const fooProto = { | |
get key() { | |
return this[key] | |
} | |
}; | |
function makeFoo() { | |
const foo = Object.create(fooProto); | |
foo[key] = 'my secret key'; | |
return foo; | |
} | |
const foo = makeFoo(); | |
console.log(foo.key) | |
// => 'my secret key' | |
console.log(foo[key]) | |
// => 'my secret key' | |
console.log(foo[Symbol('my key')]) | |
// => undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment