JS Built-ins
← Set77 / 85
SetisSupersetOfintermediate

Set isSupersetOf() β€” non-superset is false

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

Use Set.isSupersetOf() to check whether a set contains all elements of another set.

Set.prototype.isSupersetOf() (ES2025)

If B has an element not in A, isSupersetOf returns false.

Challenge: Verify that a non-superset returns false.

πŸ’‘ Hints (1)
  • β€’ isSupersetOf returns false if any element of B is missing from A