- Symbol
- well-known symbols
- Reflect.ownKeys
- Object.hasOwn
A Symbol is a unique primitive often used as a property key to avoid naming collisions. Well-known symbols customize language protocols such as iteration. Reflection APIs inspect and operate on objects. Symbols do not make data secret; code with the key can still access it.
JSON.stringify and Object.keys do not include symbol-keyed properties.
Add string and symbol keys, inspect them with different APIs, and implement a custom Symbol.iterator method.
Open example.html, inspect example.js, then edit and refresh. For APIs that need an origin, run a local server from the JavaScripts folder.
- Explain the behavior and its limits in your own words.
- Test a normal case and a failure or cleanup case.
- Record when this feature is useful and when a simpler approach is better.