JavaScript · Middle · Question 29 of 75
What is Symbol used for?
- ✓Correct answer: For unique property keys that don't clash with others
- 2For storing short strings while saving engine memory
- 3For declaring constants that can't be reassigned
Explanation
Symbol('id') is always unique, and symbol keys don't show up in for...in or Object.keys. Built-in "well-known" symbols customize object behavior: Symbol.iterator, Symbol.toPrimitive, Symbol.asyncIterator.