PRACTICE / UNDERSTAND / REPEAT

JavaScript: Collections

Practice collections with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

20 questionsAnswers explainedFree · no login
Question 1 of 20
Collections · MCQQuestion link ↗

What is the size of this Set?

console.log(new Set([1, 1, 2]).size);
Choose one answer
Answer & explanation

Answer: 2

A Set stores distinct values; the repeated first number is stored once.