Wax seals at Bayu’s counter: are two Symbol("x") equal? Use a seal as a drawer’s key, then see who sees it, Object.keys, JSON or Reflect.ownKeys, and what…
A Symbol is a key that cannot clash: a library can hang data on someone else’s object without overwriting anything, and that data stays out of Object.keys and JSON. Symbols are also what the language’s protocols are built on (Symbol.iterator), and Symbol.for is how parts of a program share one Symbol.
A Symbol is a value that equals only itself
Symbol('x') === Symbol('x') Always false: every call of Symbol() makes a new value. Its argument is only a label. When two parts of a program need the same Symbol, share the value, or use Symbol.for(key).JSON.stringify or Object.keys Both read text keys only. The key is still there: Reflect.ownKeys(o) or Object.getOwnPropertySymbols(o) sees it, and a spread copies it. Do not keep data that must be serialised under a Symbol.new Symbol() throws, and a Symbol will not become text by itself Symbol is not a constructor: call Symbol() without new. A template literal and + throw a TypeError on a Symbol; write String(s) or s.description when you want its text.a.description or String(a).