JavaScript Objects Quiz
Objects are stored and compared by reference, and their keys are always strings or symbols. That explains most object surprises, from {} === {} being false to keys overwriting each other.
These questions cover references, shallow copies, key order and serialization.
Objects questions
- Why do object keys 1 and "1" overwrite each other?
- What happens when you use an object as an object key?
- Why is {} === {} false in JavaScript?
- Are JavaScript objects copied by reference?
- Does the spread operator make a deep copy?
- Is Object.freeze deep or shallow?
- In what order does Object.keys return keys?
- Why does JSON.stringify drop undefined and functions?
- What is the difference between in and hasOwnProperty?
- How does optional chaining short-circuit in JavaScript?
- What does the rest operator do in object destructuring?
- Why can a Map have both 1 and "1" as keys?