set.isSubsetOf(other) checks whether every value of set is also in other. It returns true if nothing in the first Set is missing from the second, and false if even one value is missing.
Think of it as "is my list fully covered by that list?" The method returns only a boolean. It does not create a new Set and does not change either Set. The argument must be a Set or a set-like object such as a Map.
Remember
small.isSubsetOf(big)
every value of small is in big → true
one value of small is missing → false
An empty Set is a subset of every Set
A Set is a subset of itself
Direction matters: ask the smaller Set
Syntax
Call it on the Set you want to test, and pass the bigger Set. Use the boolean in an if statement.
JavaScript
const needed = new Set(["html", "css"]);
const known = new Set(["html", "css", "js"]);
console.log(needed.isSubsetOf(known)); // true
console.log(known.isSubsetOf(needed)); // false
Call
What it does
a.isSubsetOf(b)
true if every value of a is in b.
b.isSupersetOf(a)
The same question asked from the bigger Set.
a.difference(b).size === 0
The same check, but it builds a whole new Set first.
a.isSubsetOf(map)
A Map works as the argument, and its keys are compared.
// ECMAScript 2025
Set.prototype.isSubsetOf(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
Parameter
Description
other
Required. 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 Value
Description
true
Every value of the Set is also in other. This includes the case of two equal Sets, and the case of an empty Set.
false
At least one value of the Set is missing from other.
TypeError (thrown)
other is not set-like, for example an array or a number.
JavaScript Examples
Example 1 — Check Whether a Set Is Covered
A job needs two skills. Check if a candidate knows all of them, in both directions.
JavaScript
const needed = new Set(["html", "css"]);
const known = new Set(["html", "css", "js"]);
const partial = new Set(["html", "python"]);
console.log("needed in known: " + needed.isSubsetOf(known));
console.log("needed in partial: " + needed.isSubsetOf(partial));
console.log("known in needed: " + known.isSubsetOf(needed));
needed in known: true
needed in partial: false
known in needed: false
The Try It page first checks that Set.prototype.isSubsetOf() 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
Fully covered. Both html and css are in known, so needed.isSubsetOf(known) is true.
Missing one.partial has html but not css, so the answer is false.
Opposite direction.known has js, which needed does not have, so known.isSubsetOf(needed) is false.
Example 2 — Equal and Empty Sets
Two special cases: a Set and its copy, and an empty Set. Then check how a strict subset can be tested.
The Try It page first checks that Set.prototype.isSubsetOf() 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
Equal Sets.copy has exactly the same values, so each value of a is found in it. The answer is true.
Empty Set. An empty Set has no value that could be missing, so it is a subset of every Set, and a Set is also a subset of itself.
Strict subset. To require that the other Set has extra values, also compare the sizes. Both sizes are 3, so a.size < copy.size is false.
Example 3 — Check a Checklist and Use a Map
Check that every required step is done. A Map can also be the argument, and its keys are compared.
JavaScript
const required = new Set(["design", "code", "test"]);
const done = new Set(["design", "code"]);
console.log("Ready: " + required.isSubsetOf(done));
done.add("test");
console.log("Ready now: " + required.isSubsetOf(done));
const status = new Map([["design", true], ["code", true], ["test", false], ["docs", false]]);
console.log("Keys of the Map cover it: " + required.isSubsetOf(status));
Ready: false
Ready now: true
Keys of the Map cover it: true
The Try It page first checks that Set.prototype.isSubsetOf() 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
Not ready yet."test" is required but is not in done, so the answer is false.
Finish the step. After done.add("test"), every required step is in done, so the same check now returns true.
A Map argument. Only the keys are compared. The Map has design, code and test as keys (the true or false values do not matter), so it covers the required Set.
Compatibility
Browser & Runtime Support
Set.prototype.isSubsetOf() 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.isSubsetOf()
Supported in Chrome 122+, Edge 122+, Firefox 127+, Safari 17+, Opera 108+ and Node.js 22+. Internet Explorer never got it.
ES2025Standard since
Google Chrome122+ · Desktop & Mobile
Full support
Microsoft Edge122+ · Chromium based
Full support
Mozilla Firefox127+ · Desktop & Mobile
Full support
Apple Safari17+ · macOS & iOS
Full support
Opera108+ · Chromium based
Full support
Samsung Internet26+ · Android
Supported
Android WebView122+ · Chromium based
Supported
Node.js22+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
set.isSubsetOf()Recent browsers
Bottom line: Check support with typeof Set.prototype.isSubsetOf === "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 every value of the Set is also in the other Set. It returns true if nothing is missing and false if at least one value is not found.
Yes. An empty Set has no value that could be missing from another Set, so isSubsetOf() returns true. A Set is also a subset of itself and of any Set with the same values.
Combine the check with a size comparison: a.isSubsetOf(b) && a.size < b.size. This means b has at least one extra value.
They ask the same question from two sides. a.isSubsetOf(b) is true when b contains all of a, and that is the same as b.isSupersetOf(a).
Use [...a].every((x) => b.has(x)). It returns true when every value of a is found in b, which is the same answer.