What is the output of the following? “`js const s = new Set([1, 2, 2, 3, 3, 3]); console.log([…s]); console.log(s.size); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js const s = new Set([1, 2, 2, 3, 3, 3]); console.log([…s]); console.log(s.size); “`

Key points

  • Set objects in JavaScript only store unique values
  • Duplicates are automatically removed when adding elements to a Set
  • The size property of a Set object returns the number of unique elements
  • The output of the code includes the unique elements and the size of the Set

Ready to go further?

Related questions