Get to know MDN better
Since June 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The isSubsetOf() method of Set instances takes a set and returns a boolean indicating if all elements of this set are in the given set.
A Set object, or set-like object.
true if all elements in this set are also in the other set, and false otherwise.
In mathematical notation, subset is defined as:
A⊆B⇔∀x∊A,x∊BA\subseteq B \Leftrightarrow \forall x\in A,\,x\in BAnd using Venn diagram:
Note: The subset relationship is not proper subset, which means isSubsetOf() returns true if this and other contain the same elements.
isSubsetOf() accepts set-like objects as the other parameter. It requires this to be an actual Set instance, because it directly retrieves the underlying data stored in this without invoking any user code. Then, its behavior depends on the sizes of this and other:
The set of multiples of 4 (<20) is a subset of even numbers (<20):
The set of prime numbers (<20) is not a subset of all odd numbers (<20), because 2 is prime but not odd:
Equivalent sets are subsets of each other:
| ECMAScript® 2027 Language Specification # sec-set.prototype.issubsetof |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 22, 2026 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.