JS Built-ins
← Set73 / 85
SetisSubsetOfintermediate

Set isSubsetOf() β€” empty set is subset of everything

πŸ“– Usage Example
const a = new Set([1, 2])
const b = new Set([1, 2, 3])
a.isSubsetOf(b)   // β†’ true
b.isSubsetOf(a)   // β†’ false

Use Set.isSubsetOf() to check whether every element of this set is also in another set.

Set.prototype.isSubsetOf() (ES2025)

The empty Set is a subset of every Set.

Challenge: Verify that the empty Set is a subset of any Set.

πŸ’‘ Hints (1)
  • β€’ The empty Set has no elements that could be missing from B, so it is always a subset