JS Built-ins
← Set71 / 85
SetisSubsetOfintermediate

Set isSubsetOf() β€” subset is true

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

setA.isSubsetOf(setB) returns true if all elements of A are in B.

Challenge: Verify that a subset returns true.

πŸ’‘ Hints (1)
  • β€’ isSubsetOf returns true if every element of A exists in B