Creates an array of unique values, in order, from all given arrays using SameValueZero for equality comparisons. Part of Lodash Array (stable in 4.x — not deprecated).
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.union on an array. Start with this line.
Lodash
_.union([arrays])
Call
What it does
_.union([arrays])
Primary signature.
_.union(array)
Call with an array argument.
Prefer import union from "lodash/union" when you want a smaller bundle.
Library declarations
Lodash
_.union([arrays])
Parameters
Parameter
Description
arrays
Optional. Sources to merge; scanned in argument order
Return Value
Return Value
Description
*
New array of unique values
Lodash Examples
Example 1 — Official: Two Arrays
Merge unique values; the first occurrence wins placement.
Not coerced. Union does not treat falsy values as the same.
Contrast. Objects still compare by reference — use _.unionBy for keys.
Compatibility
Browser & Runtime Support
_.union is a Lodash 4.x Array helper (available since early Lodash). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.union()
Available in [email protected] full builds and the lodash/union modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.unionLodash 4.x+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import union from "lodash/union" for smaller builds. Native Set can dedupe one list; multi-array union still needs a merge step.
Frequently Asked Questions
_.union(...arrays) creates a new array of unique values from all given arrays, using SameValueZero equality. Order follows first-seen appearance as arguments are scanned left to right.
No. It returns a new array. Each argument stays unchanged.
uniq dedupes one array. union concatenates many arrays (one level) then dedupes — like concat + uniq across arguments.
union keeps values that appear in any array. intersection keeps only values present in every array.
Use _.unionBy when equality should run on a projected key (like a property). Use _.unionWith for a custom comparator function.
Use import union from "lodash/union" or require("lodash/union") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.union.