JS Built-ins
← Set74 / 85
SetisSubsetOfintermediate

Set isSubsetOf() β€” equal sets are subsets

πŸ“– 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 Set is a subset of itself (equal sets are subsets of each other).

Challenge: Verify that equal Sets are subsets of each other.

πŸ’‘ Hints (1)
  • β€’ A set is always a subset of itself or any equal set