union es-toolkit
Creates a new array containing all unique elements from two arrays.
Usage
union(arr1, arr2)
Use union when you want to combine all elements from multiple arrays without duplicates. It merges two arrays and returns a new array with duplicate values removed.
Elements from the first array come first, followed by unique elements from the second array.
Parameters
arr1T[]required
The first array to merge.
arr2T[]required
The second array to merge.
Returns
Returns a new array containing all unique elements from both arrays.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.