Question 7
Back to Exercise
What is new Set([{ id: 1 }, { id: 1 }]).size?
- A 1
- B 0
- C It throws
- D 2 – objects are compared by reference, and these are two different objects Correct
Correct Answer: Option D
Sets use SameValueZero: primitives by value, objects by identity. Deduplicate objects with a Map keyed by id.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!