Creates a duplicate-free version of an array. Uniqueness is decided by the iteratee result for each element, compared with SameValueZero. Only the first element per projected key 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 _.uniqBy on an array. Start with this line.
Lodash
_.uniqBy(array, [iteratee=_.identity])
Call
What it does
_.uniqBy(array, [iteratee=_.identity])
Primary signature.
_.uniqBy(array)
Call with an array argument.
Prefer import uniqBy from "lodash/uniqBy" when you want a smaller bundle.
uniq. Two object literals are different references → both kept.
uniqBy. Both project to 1 → only the first kept.
Choose By when uniqueness is about a field or formula.
Choose With when you need a custom comparator (deep equal, etc.).
Compatibility
Browser & Runtime Support
_.uniqBy 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+
_.uniqBy()
Available in [email protected] full builds and the lodash/uniqBy 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
_.uniqByLodash 4.0.0+
Bottom line: Safe for production once Lodash 4.x is loaded. Prefer import uniqBy from "lodash/uniqBy" for smaller builds.
Frequently Asked Questions
_.uniqBy(array, iteratee) creates a duplicate-free array. Uniqueness is decided by the iteratee result for each element (SameValueZero). Only the first element per projected key is kept.
No. It returns a new array. The source is unchanged.
uniq compares whole values. uniqBy compares the iteratee output — e.g. Math.floor or a property like "id".
A function, a property string ("x"), a path, or identity when omitted. Lodash’s iteratee shorthand applies.
When the array is already sorted by the same iteratee so duplicates sit next to each other — sortedUniqBy only compares neighbors.
Use import uniqBy from "lodash/uniqBy" or require("lodash/uniqBy") for tree-shaking. Full build: import _ from "lodash" then _.uniqBy.