Created
March 13, 2021 16:51
-
-
Save NovoManu/eb966892def7b439eb3035977c9b7a40 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 symbol1 = Symbol() | |
const symbol2 = Symbol('id') | |
const symbol3 = Symbol('id') | |
// Each symbol is unique | |
console.log(symbol2 !== symbol3) | |
// Symbols could be used as object keys | |
const obj = { | |
[symbol1]: 'War', | |
[symbol2]: 'is', | |
[symbol3]: 'Peace', | |
} | |
console.log(`${obj[symbol1]} ${obj[symbol2]} ${obj[symbol3]}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment