set.isDisjointFrom(other) checks whether two Sets have nothing in common. It returns true when no value appears in both Sets, and false when at least one value is shared.
Two Sets that do not overlap are called disjoint. The method only answers true or false: it does not create a new Set and it does not change either Set. The argument must be a Set or a set-like object such as a Map.
Remember
a.isDisjointFrom(b)
no shared value → true
one or more shared → false
An empty Set is disjoint from every Set
Same as: a.intersection(b).size === 0
Returns a boolean, not a Set
Syntax
Call it on a Set and pass another Set. Use the boolean in an if statement.
// ECMAScript 2025
Set.prototype.isDisjointFrom(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
The two Sets have no value in common.
false
At least one value is in both Sets.
TypeError (thrown)
other is not set-like, for example an array or a number.
JavaScript Examples
Example 1 — Check Whether Two Sets Overlap
Compare weekdays with the weekend, and then with a Set that shares one day.
JavaScript
const weekdays = new Set(["mon", "tue", "wed"]);
const weekend = new Set(["sat", "sun"]);
const midweek = new Set(["wed", "thu"]);
console.log("Weekdays vs weekend: " + weekdays.isDisjointFrom(weekend));
console.log("Weekdays vs midweek: " + weekdays.isDisjointFrom(midweek));
Weekdays vs weekend: true
Weekdays vs midweek: false
The Try It page first checks that Set.prototype.isDisjointFrom() 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
No shared day.weekdays and weekend have no value in common, so the answer is true.
One shared day."wed" is in both weekdays and midweek, so the answer is false.
Only a yes or no. The method does not tell you which value is shared. Use intersection() if you need to see it.
Example 2 — Empty Sets and a Map
See what happens with an empty Set and with the same Set. A Map can be the argument, and its keys are compared.
JavaScript
const nums = new Set([1, 2, 3]);
console.log("Empty Set: " + nums.isDisjointFrom(new Set()));
console.log("Itself: " + nums.isDisjointFrom(nums));
const lookup = new Map([[3, "three"], [9, "nine"]]);
console.log("Map with key 3: " + nums.isDisjointFrom(lookup));
const other = new Map([[7, "seven"]]);
console.log("Map without shared key: " + nums.isDisjointFrom(other));
Empty Set: true
Itself: false
Map with key 3: false
Map without shared key: true
The Try It page first checks that Set.prototype.isDisjointFrom() 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
Empty Set. Nothing in an empty Set can be shared, so the answer is true.
Itself. A Set that has values shares all of them with itself, so the answer is false.
Map keys. The Map is compared by its keys. 3 is a key and is also in nums, so the first Map gives false. The second Map has only key 7, so the answer is true.
Example 3 — Check Permissions
A practical use: find out whether a user has any of the blocked permissions.
JavaScript
const blocked = new Set(["delete", "admin"]);
const ann = new Set(["read", "write"]);
const bob = new Set(["read", "delete"]);
function check(name, permissions) {
if (permissions.isDisjointFrom(blocked)) {
console.log(name + ": allowed");
} else {
console.log(name + ": blocked");
}
}
check("Ann", ann);
check("Bob", bob);
The Try It page first checks that Set.prototype.isDisjointFrom() 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
A list to avoid.blocked holds the permissions that must not be given.
Ann. She has read and write. None of them is blocked, so the two Sets are disjoint and she is allowed.
Bob. He has delete, which is also in blocked. The Sets overlap, so the answer is false and he is blocked.
Compatibility
Browser & Runtime Support
Set.prototype.isDisjointFrom() 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.isDisjointFrom()
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.isDisjointFrom()Recent browsers
Bottom line: Check support with typeof Set.prototype.isDisjointFrom === "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 that two Sets have no value in common. It returns true when they do not overlap and false when at least one value appears in both.
Yes. An empty Set has no values, so nothing can be shared, and the answer is always true.
isDisjointFrom() only returns true or false. intersection() builds a new Set with the shared values. Use isDisjointFrom() when you only need the yes or no answer.
No. The argument must be a Set or a set-like object such as a Map. An array throws a TypeError. Use new Set(array) to convert it first.
Use [...a].every((x) => !b.has(x)). It returns true when no value of a is found in b, which is the same answer.