On this page
  1. Set.union
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Set.union

Prev: add | Up: Set | Next: String
Rel: Set, Collections Guide
Ref: MDN Web Docs — Set.union
Tags: #public #web #javascript #builtins #set #tier/standard


Signature & Overview

set.union(other)  /* + intersection(), difference(), symmetricDifference() */

Returns a new Set combining elements of both sets without mutating either (ES2025).

Notes & Pitfalls

Example

const a = new Set([1, 2]);
const b = new Set([2, 3]);
const combined = a.union(b);
console.assert(combined.size === 3 && combined.has(3));

Linked from

Related notes