-
-
Save brigand/3c44f31b663894a0d0d1 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') | |
function makeFoo(){ | |
return { | |
[KEY]: 'my secret key', | |
get key(){ | |
return this[KEY]; | |
} | |
}; | |
} | |
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