I recently learned about Symbols in JavaScript ES6, and I was very curious about how it is implemented underneath the hood.
Specifically, I am curious about how Symbols are implemented to achieve uniqueness:
a = Symbol('key')
b = Symbol('key')
a !== b // true
But can also achieve its for
functionality:
a = Symbol.for('key')
b = Symbol.for('key')
a === b // true
Can anyone shed some light on how this is implemented underneath the hood?
I read the MDN documentation, but it mainly described the interface, rather than the implementation.