Lesson content
Read, practise, then check your understanding
Every Symbol(description) is unique; the description aids debugging but does not define identity. Symbols can be property keys without colliding with ordinary strings.
Protocol hooks
const internalId = Symbol("internalId");
const record = { name: "Mira", [internalId]: 42 };
const shared = Symbol.for("app.status");
console.log(Symbol.keyFor(shared));
Global-registry symbols coordinate known keys across code in one realm. Well-known symbols such as Symbol.iterator, toStringTag, and hasInstance customize language operations. Object.keys excludes symbols; use Object.getOwnPropertySymbols or Reflect.ownKeys. Symbols reduce accidental collision but are not privacy—use private fields or closures for enforced hiding.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.