JS Built-ins
← Set75 / 85
SetisSubsetOfintermediate

Set isSubsetOf() β€” single element check

πŸ“– 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)

A single-element Set is a subset if that element exists in B.

Challenge: Verify single-element subset behavior.

πŸ’‘ Hints (1)
  • β€’ For a single-element set, isSubsetOf reduces to has() on B