CKTIS / JavaScript
Set.prototype.isSubsetOf — testing subset membership
Set.prototype.isSubsetOf checks whether every element of a set occurs in another set or set-like object. It returns a boolean; equal sets also satisfy this condition.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
set.isSubsetOf(other)set.isSubsetOf(other) returns true when every element of set belongs to other; otherwise it returns false. This is not a proper-subset test: a set is a subset of itself. An empty set is a subset of every valid set. The method itself does not modify the sets.
The receiver set must be an actual Set object. The argument other can be a Set or an object with a size property and callable has and keys methods, such as a Map, whose keys are tested. Being iterable is insufficient: an array is not a valid argument. The method requires callable keys even though it does not call it.
After validating the argument, the method returns false if the number of elements stored internally in set exceeds the size of other. This comparison does not read the set.size property. Otherwise, the method checks elements through other.has, stopping at the first missing element. For ordinary sets, objects are compared by identity, not contents. Custom argument getters and methods can cause side effects or throw exceptions.
The method belongs to ECMAScript 2025, not Web APIs. The specification does not establish support in a particular browser; Node 24 in a repository does not prove it either. Check typeof Set.prototype.isSubsetOf === "function" in the target runtime.
Examples
const required = new Set(["read"]);
const granted = new Set(["read", "write"]);
console.log(required.isSubsetOf(granted));
console.log(granted.isSubsetOf(required));
console.log(required.isSubsetOf(required));
console.log(new Set().isSubsetOf(granted));Result
true false true true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.