Like _.uniq, but you pass a comparator invoked as (arrVal, othVal). Return truthy when two elements should count as duplicates. Only the first of each group is kept. Order follows the original array. Since Lodash 4.0.0.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.uniqWith on an array. Start with this line.
Lodash
_.uniqWith(array, [comparator])
Call
What it does
_.uniqWith(array, [comparator])
Primary signature.
_.uniqWith(array)
Call with an array argument.
Prefer import uniqWith from "lodash/uniqWith" when you want a smaller bundle.
Library declarations
Lodash
_.uniqWith(array, [comparator])
Parameters
Parameter
Description
array
Required. Source to dedupe
comparator
Optional. (arrVal, othVal) => boolean
Return Value
Return Value
Description
*
The value returned by _.uniqWith().
Lodash Examples
Example 1 — Official: _.isEqual
Deep-equal objects collapse — from the Lodash docs.
_.uniqWith is a Lodash Array helper (since 4.0.0). It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.uniqWith()
Available in [email protected] full builds and the lodash/uniqWith 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
_.uniqWithLodash 4.0.0+
Bottom line: Safe for production once Lodash 4.x is loaded. Prefer import uniqWith from "lodash/uniqWith" for smaller builds. Pair with lodash/isEqual when you need deep equality.
Frequently Asked Questions
_.uniqWith(array, comparator) creates a duplicate-free array. The comparator (arrVal, othVal) returns truthy when two elements should count as the same. Only the first of each duplicate group is kept.
No. It returns a new array. The source is unchanged.
uniqBy projects each element to a key and compares keys. uniqWith compares pairs of elements with your predicate — useful for deep equality or multi-field rules.
Yes. _.uniqWith(objects, _.isEqual) is the common deep-equal pattern from the official docs.
The earliest element in array order wins; later matches are skipped.
Use import uniqWith from "lodash/uniqWith" or require("lodash/uniqWith") for tree-shaking. Full build: import _ from "lodash" then _.uniqWith.