LearnFrenzy
Sign in Take a free test

ES6 Features · ES6 Features MCQ · Question 7

Set and objects Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links