What is the size of this Set?
console.log(new Set([1, 1, 2]).size);Answer & explanation
Answer: 2
A Set stores distinct values; the repeated first number is stored once.
Practice collections with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
console.log(new Set([1, 1, 2]).size);Answer: 2
A Set stores distinct values; the repeated first number is stored once.