Created
January 3, 2018 22:13
-
-
Save danielbischoff/f0a9e460642b0484a4a97e3292ecd2c9 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 hiddenSymbol = Symbol(); | |
const obj = { a: 1 }; | |
obj[hiddenSymbol] = 'hidden'; | |
// print all keys | |
const keys = Object.keys(obj); | |
console.log(keys); // prints ['a'] | |
// print value of prop hiddenSymbol | |
console.log(obj[hiddenSymbol]); // prints 'hidden' | |
// retrieve all symbol properties | |
console.log(Object.getOwnPropertySymbols(obj)); // prints [Symbol()], our symbol type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment