JS Built-ins
Setbeginner

Set Constructor β€” empty Set

πŸ“– Usage Example
const s1 = new Set()          // empty
const s2 = new Set([1, 2, 3]) // from array
console.log(s2.size) // β†’ 3

Use the Set constructor to create a new set, optionally passing an iterable.

Set Constructor

new Set() creates an empty Set with size 0.

Challenge: Verify that new Set().size equals 0.

πŸ’‘ Hints (1)
  • β€’ new Set() with no arguments creates an empty Set