On this page
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
- ES2025 native set algebra: Returns a new
Setwithout mutating either input (alongside.intersection(),.difference(),.symmetricDifference()).
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
- tuts/javascript/builtins/Set/add Linked here; links to this page; shared tags: #builtins, #javascript, #set, #tier, #web
- tuts/javascript/builtins/Set Linked here; links to this page; shared tags: #builtins, #javascript, #set, #web
- tuts/javascript/builtins/collections_map_set_weak Linked here; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/String Linked here; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Array/at shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/filter shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/find shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/flatMap shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/from shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/includes shared tags: #builtins, #javascript, #tier, #web