Performs a SameValueZero comparison between two values to decide if they are equivalent. Part of Lodash Lang since 4.0.0 (stable — not deprecated). Note: same rule as Map / Set keys — NaN equals NaN, and +0 equals -0.
Pass the value you want to inspect or convert. Read the return type carefully before you use the result.
Syntax
Call _.eq. Start with this line.
Lodash
_.eq(value, other)
Call
What it does
_.eq(value, other)
Primary signature.
_.eq(value)
Check, compare, clone, or convert a value.
Prefer import eq from "lodash/eq" when you want a smaller bundle.
Library declarations
Lodash
_.eq(value, other)
Parameters
Parameter
Description
value
Required. First value to compare
other
Required. Second value to compare
Return Value
Return Value
Description
*
true if equivalent, else false
Lodash Examples
Example 1 — Official: Same vs Different Object Refs
Objects match only when they are the same reference.
Lodash
var object = { a: 1 };
var other = { a: 1 };
console.log(_.eq(object, object)); // true
console.log(_.eq(object, other)); // false
Cost.eq is O(1); isEqual grows with structure size.
Pick. Identity / primitives → eq; deep trees → isEqual.
Compatibility
Browser & Runtime Support
_.eq is a Lodash 4.x Lang helper (since 4.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines expose related ideas via ===, Object.is, and SameValueZero in Map/Set, but not this helper by name.
✓ Stable · Lodash 4.0.0+
_.eq()
Available in [email protected] full builds and the lodash/eq 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
_.eqLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import eq from "lodash/eq" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.eq(value, other) performs a SameValueZero comparison. It returns true when the values are equivalent under that rule — including NaN === NaN and +0 === -0.
Almost, but not for NaN. Strict equality makes NaN !== NaN. _.eq(NaN, NaN) is true. Both treat +0 and -0 as equal.
No. Object.is follows SameValue and treats +0 and -0 as different. _.eq uses SameValueZero, so +0 and -0 are equal.
No. Objects and arrays are compared by reference, like ===. Use _.isEqual for deep structural equality.
It is the same equality rule used by Map and Set key matching — NaN matches NaN, and signed zeros match each other.
Use import eq from "lodash/eq" or require("lodash/eq") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.eq.