Creates a duplicate-free version of an array, using SameValueZero for equality. Only the first occurrence of each element is kept. Order follows the original array. Since Lodash 0.1.0.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.uniq on an array. Start with this line.
Lodash
_.uniq(array)
Call
What it does
_.uniq(array)
Primary signature.
_.uniq(array)
Call with an array argument.
Prefer import uniq from "lodash/uniq" when you want a smaller bundle.
uniq. Different object instances stay — only the repeated a ref is dropped.
uniqBy. Same x → one object kept.
Lesson. Prefer By/With for object identity by fields.
Primitives. Numbers and strings are the sweet spot for plain uniq.
Compatibility
Browser & Runtime Support
_.uniq is a Lodash Array helper (since 0.1.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 0.1.0+
_.uniq()
Available in [email protected] full builds and the lodash/uniq 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
_.uniqLodash 0.1.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import uniq from "lodash/uniq" for smaller builds. Native alternative: [...new Set(arr)] for primitives (NaN handling differs slightly in older engines).
Frequently Asked Questions
_.uniq(array) creates a duplicate-free version of an array using SameValueZero equality. Only the first occurrence of each element is kept. Order follows the original array.
No. It returns a new array. The source is unchanged.
No. Ordering mirrors the positions of the surviving first occurrences.
sortedUniq assumes sorted input and only collapses consecutive duplicates. uniq remembers every prior value across the whole array.
Yes. SameValueZero treats NaN as equal to NaN, so only the first NaN is kept.
Use import uniq from "lodash/uniq" or require("lodash/uniq") for tree-shaking. Full build: import _ from "lodash" then _.uniq.