JavaScript Set isSupersetOf() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Instance method

Definition

set.isSupersetOf(other) checks whether the Set contains every value of other. It returns true if nothing in other is missing from the Set, and false if at least one value is missing.

It is the mirror of isSubsetOf(): big.isSupersetOf(small) is the same question as small.isSubsetOf(big). The method returns only a boolean, and it does not change either Set.

Remember
big.isSupersetOf(small)

big has every value of small  → true
a value of small is missing   → false

Every Set is a superset of an empty Set
A Set is a superset of itself
Same as: small.isSubsetOf(big)

Syntax

Call it on the bigger Set and pass the Set whose values you want to find. Use the boolean in an if statement.

JavaScript
const known = new Set(["html", "css", "js"]);
const needed = new Set(["html", "css"]);

console.log(known.isSupersetOf(needed));   // true
console.log(needed.isSupersetOf(known));   // false
CallWhat it does
a.isSupersetOf(b)true if a contains every value of b.
b.isSubsetOf(a)The same question asked from the smaller Set.
[...b].every((x) => a.has(x))The older way to write the same check.
a.isSupersetOf(map)A Map works as the argument, and its keys are compared.

A standard JavaScript method (ES2025) on every Set, from Set.prototype. It works in current browsers and in Node.js 22 or newer. Siblings: add(), clear(), delete(), difference(), entries(), forEach(), has(), intersection(), isDisjointFrom(), isSubsetOf(), keys(), symmetricDifference(), union(), values(), [Symbol.iterator]().

Library declarations
JavaScript
// ECMAScript 2025
Set.prototype.isSupersetOf(other)

// other  : a Set, or a set-like object (needs size, has() and keys())
// returns: true or false
// throws : TypeError if other is not set-like (for example an array)

Parameters

ParameterDescription
otherRequired. A Set, or any set-like object: an object with a numeric size and the methods has() and keys(). A Map is set-like. An array is not, so convert it with new Set(array).

Return Value

Return ValueDescription
trueThe Set contains every value of other. This includes equal Sets, and the case where other is empty.
falseAt least one value of other is not in the Set.
TypeError (thrown)other is not set-like, for example an array or a number.

JavaScript Examples

Example 1 — Check That a Set Has Everything

A team knows several skills. Check if it covers what a project needs, and what happens in the opposite direction.

JavaScript
const team = new Set(["html", "css", "js", "sql"]);
const project = new Set(["html", "js"]);
const bigProject = new Set(["html", "js", "python"]);

console.log("Team covers project: " + team.isSupersetOf(project));
console.log("Team covers big project: " + team.isSupersetOf(bigProject));
console.log("Project covers team: " + project.isSupersetOf(team));
Try It Yourself

The Try It page first checks that Set.prototype.isSupersetOf() exists, because it is new in ES2025. In an older browser it prints a short explanation and the output above. In current browsers and in Node.js 22 or newer, it runs the code for real.

How It Works

  1. Covered. html and js are both in team, so team.isSupersetOf(project) is true.
  2. One is missing. python is not in team, so the big project is not covered and the answer is false.
  3. Wrong direction. The small Set cannot contain everything in the bigger one, so the last line is false.

Example 2 — Equal and Empty Sets

Special cases: an empty Set, an equal copy, and the sizes you can use to ask for a strict superset.

JavaScript
const a = new Set([1, 2, 3]);
const copy = new Set([1, 2, 3]);

console.log("Empty Set: " + a.isSupersetOf(new Set()));
console.log("Equal copy: " + a.isSupersetOf(copy));
console.log("Empty is superset of a: " + new Set().isSupersetOf(a));

const strict = a.isSupersetOf(copy) && a.size > copy.size;
console.log("Strict superset: " + strict);
Try It Yourself

The Try It page first checks that Set.prototype.isSupersetOf() exists, because it is new in ES2025. In an older browser it prints a short explanation and the output above. In current browsers and in Node.js 22 or newer, it runs the code for real.

How It Works

  1. Every Set has an empty one inside. There is no value in the empty Set that could be missing, so the answer is true.
  2. Equal copy. a has every value of copy, so it is a superset of it. An empty Set, on the other hand, is not a superset of a Set that has values.
  3. Strict superset. To require extra values, also compare the sizes. Both are 3, so a.size > copy.size is false.

Example 3 — A Feature Check with a Map

A plan must include all required features. Check it with a Set, then with the keys of a Map.

JavaScript
const required = new Set(["login", "search"]);

const basic = new Set(["login"]);
const pro = new Set(["login", "search", "export"]);

console.log("Basic plan: " + basic.isSupersetOf(required));
console.log("Pro plan: " + pro.isSupersetOf(required));

const prices = new Map([["login", 0], ["search", 5], ["export", 9]]);
console.log("Set covers the keys: " + new Set(prices.keys()).isSupersetOf(required));
Try It Yourself

The Try It page first checks that Set.prototype.isSupersetOf() exists, because it is new in ES2025. In an older browser it prints a short explanation and the output above. In current browsers and in Node.js 22 or newer, it runs the code for real.

How It Works

  1. Basic plan. It has login but not search, so it is not a superset of required.
  2. Pro plan. It has both required features and an extra one, so the answer is true. Extra values do no harm.
  3. From Map keys. prices.keys() gives the feature names, and new Set(...) turns them into a Set that can be checked in the same way.

Browser & Runtime Support

Set.prototype.isSupersetOf() is one of the new Set methods added in ES2025. It works in current browsers and in Node.js 22 or newer, but not in older versions.

✓ Newer · ES2025

set.isSupersetOf()

Supported in Chrome 122+, Edge 122+, Firefox 127+, Safari 17+, Opera 108+ and Node.js 22+. Internet Explorer never got it.

ES2025 Standard since
Google Chrome 122+ · Desktop & Mobile
Full support
Microsoft Edge 122+ · Chromium based
Full support
Mozilla Firefox 127+ · Desktop & Mobile
Full support
Apple Safari 17+ · macOS & iOS
Full support
Opera 108+ · Chromium based
Full support
Samsung Internet 26+ · Android
Supported
Android WebView 122+ · Chromium based
Supported
Node.js 22+ · Server runtime
Supported
Deno Recent versions · JavaScript runtime
Supported
Bun Recent versions · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
set.isSupersetOf() Recent browsers

Bottom line: Check support with typeof Set.prototype.isSupersetOf === "function". For older browsers, the same result can be made with the spread syntax and filter(), or with a loop.

Frequently Asked Questions

It checks whether the Set contains every value of another Set. It returns true if nothing is missing and false if at least one value is not found.
Yes. An empty Set has no values that could be missing, so isSupersetOf(new Set()) is always true. A Set is also a superset of itself.
They ask the same question from the two sides. big.isSupersetOf(small) is the same as small.isSubsetOf(big). Pick the one that reads more naturally in your code.
Combine the check with a size comparison: a.isSupersetOf(b) && a.size > b.size. This means a has at least one value that b does not have.
Use [...b].every((x) => a.has(x)). It returns true when every value of b is found in a, which is the same answer.

Next: keys()

Learn how to get an iterator of the values of a Set, and why keys() and values() are the same method.

keys() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful