When would you use a symbol type in JS?
I'm looking for practical examples, not theoretical 

-
-
Replying to @Una
Unique keys on an object const classRoom = { [Symbol('Mark')]: { grade: 50 }, [Symbol('olivia')]: { grade: 80 }, [Symbol('olivia')]: { grade: 90 } } Storing Metadata about other objects, or even DOM notes Symbol(document.querySelector(‘h2’))
5 replies 3 retweets 32 likes -
Say you wanted to track clicks on a Dom element, you can use the symbol of that Dom element as a property on an object - you don’t need to assign a unique ID to each Dom element to keep track of them
5 replies 1 retweet 30 likes
Why not just use a WeakMap in that case?
2:37 PM - 29 Oct 2018
0 replies
2 retweets
9 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.