JS Built-ins
← Set58 / 85
Setintersectionintermediate

Set intersection() β€” no common elements

πŸ“– Usage Example
const a = new Set([1, 2, 3])
const b = new Set([2, 3, 4])
const common = a.intersection(b)
console.log([...common]) // β†’ [2, 3]

Use Set.intersection() to get the values present in both sets.

Set.prototype.intersection() (ES2025)

Intersection of disjoint Sets is an empty Set.

Challenge: Verify that intersection of disjoint Sets is empty.

πŸ’‘ Hints (1)
  • β€’ Disjoint Sets share no elements, so their intersection is empty