Lodash _.isEqual() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Performs a deep comparison between two values to determine if they are equivalent. Objects are compared by their own enumerable properties. Since Lodash 0.1.0.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.isEqual. Start with this line.

Lodash
_.isEqual(value, other)
CallWhat it does
_.isEqual(value, other)Primary signature.
_.isEqual(value)Check, compare, clone, or convert a value.

Prefer import isEqual from "lodash/isEqual" when you want a smaller bundle.

Library declarations
Lodash
_.isEqual(value, other)

Parameters

ParameterDescription
valueRequired. First value to compare
otherRequired. Second value to compare

Return Value

Return ValueDescription
*true if equivalent, else false

Lodash Examples

Example 1 — Official: Objects vs ===

Same shape, different references — deep equal wins.

Lodash
var object = { a: 1 };
var other = { a: 1 };

_.isEqual(object, other);
// → true

object === other;
// → false
Try It Yourself

How It Works

  1. Two objects are created separately.
  2. === checks reference → false.
  3. isEqual compares own key a → both 1.
  4. Result. Deep match → true.

Example 2 — Nested Objects and Arrays

Deep walk compares nested structure.

Lodash
var a = { user: { id: 7, roles: ["admin", "editor"] } };
var b = { user: { id: 7, roles: ["admin", "editor"] } };

_.isEqual(a, b);
// → true

_.isEqual(a, { user: { id: 7, roles: ["editor", "admin"] } });
// → false  // array order matters
Try It Yourself

How It Works

  1. Nested object and array are compared recursively.
  2. Same order in roles → equal.
  3. Swapped roles → arrays differ → not equal.
  4. Lesson. Array equality is ordered, not a set.

Example 3 — Date Objects

Dates compare by time value, not by reference.

Lodash
_.isEqual(new Date(0), new Date(0));
// → true

_.isEqual(new Date(0), new Date(1));
// → false
Try It Yourself

How It Works

  1. Two Date instances at epoch ms 0.
  2. isEqual compares their time values → match.
  3. Different ms → not equal.
  4. vs === would be false even for same ms (different refs).

Example 4 — NaN Equals NaN

Unlike ===, deep equal treats NaN as matching NaN.

Lodash
NaN === NaN;
// → false

_.isEqual(NaN, NaN);
// → true
Try It Yourself

How It Works

  1. === follows IEEE rules → NaN never equals itself.
  2. isEqual uses a SameValueZero-style rule for NaN.
  3. Result. true for NaN vs NaN.
  4. Also handy inside nested objects containing NaN.

Example 5 — Functions Compare by Identity

Identical source text is not enough — same reference required.

Lodash
function greet() { return "hi"; }
var copy = function () { return "hi"; };

_.isEqual(greet, greet);
// → true

_.isEqual(greet, copy);
// → false
Try It Yourself

How It Works

  1. Same function reference → equal.
  2. Different function with same body → not equal.
  3. Docs rule: functions use ===, not source compare.
  4. DOM nodes follow the same identity rule.

Browser & Runtime Support

_.isEqual is a Lodash Lang helper (since 0.1.0). It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 0.1.0+

_.isEqual()

Available in [email protected] full builds and the lodash/isEqual modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isEqual Lodash 0.1.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import isEqual from "lodash/isEqual" for smaller builds. Use isEqualWith when you need custom field rules.

Frequently Asked Questions

_.isEqual(value, other) performs a deep comparison and returns true if the values are equivalent. Objects are compared by their own enumerable properties.
=== compares object/array references. _.isEqual walks nested values and compares structure and content — so two different objects with the same shape can be equal.
No. Functions and DOM nodes are compared by strict identity (===), not by source text or markup.
Yes. Lodash deep-compares Map and Set contents, plus arrays, dates, regexes, typed arrays, and more.
Yes for _.isEqual — unlike ===, which is false for NaN === NaN.
Use import isEqual from "lodash/isEqual" or require("lodash/isEqual") for tree-shaking. Full build: import _ from "lodash" then _.isEqual.

Next: _.isEqualWith()

Customize deep equality with a customizer callback.

_.isEqualWith() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful