Set has union and difference now
The spread-and-filter dance for set operations is over.
const a = new Set([1, 2, 3]);
const b = new Set([2, 3, 4]);
a.union(b); // {1, 2, 3, 4}
a.intersection(b); // {2, 3}
a.difference(b); // {1}
a.isSubsetOf(b); // falseShipped in Node 22 and the current browsers. The names are the maths names, which makes the code read as the intent.
javascript