Lodash _.isEqualWith() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Like _.isEqual, but accepts a customizer to decide how values compare. If the customizer returns undefined, Lodash falls back to default deep equality. Since Lodash 4.0.0.

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

Syntax

Call _.isEqualWith. Start with this line.

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

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

Library declarations
Lodash
_.isEqualWith(value, other, customizer)

Parameters

ParameterDescription
valueRequired. First value to compare
otherRequired. Second value to compare
customizerOptional. Optional compare hook (*omit → like isEqual)

Return Value

Return ValueDescription
*true if equivalent, else false

Lodash Examples

Example 1 — Official: Greeting Customizer

Treat hi and hello as the same string for equality.

Lodash
function isGreeting(value) {
  return /^h(?:i|ello)$/.test(value);
}

function customizer(objValue, othValue) {
  if (isGreeting(objValue) && isGreeting(othValue)) {
    return true;
  }
}

var array = ["hello", "goodbye"];
var other = ["hi", "goodbye"];

_.isEqualWith(array, other, customizer);
// → true

_.isEqual(array, other);
// → false
Try It Yourself

How It Works

  1. isGreeting matches hi or hello.
  2. Index 0: both greetings → customizer returns true.
  3. Index 1: returns nothing → default compare of "goodbye".
  4. Result. Arrays equal with customizer; plain isEqual is false.

Example 2 — Case-Insensitive Strings

Compare strings ignoring letter case; leave other types to Lodash.

Lodash
function caseCustomizer(a, b) {
  if (typeof a === "string" && typeof b === "string") {
    return a.toLowerCase() === b.toLowerCase();
  }
}

_.isEqualWith({ name: "Ada" }, { name: "ada" }, caseCustomizer);
// → true

_.isEqual({ name: "Ada" }, { name: "ada" });
// → false
Try It Yourself

How It Works

  1. Both values are strings → lowercased compare.
  2. Non-strings get undefined → default deep rules.
  3. Objects still walk nested keys; only string pairs are customized.
  4. Lesson. Narrow overrides keep the rest of Lodash behavior.

Example 3 — Ignore a Property Key

Skip noisy fields (timestamps, ids) using the key argument.

Lodash
function ignoreUpdatedAt(a, b, key) {
  if (key === "updatedAt") {
    return true;
  }
}

var left = { id: 1, name: "Ada", updatedAt: "2024-01-01" };
var right = { id: 1, name: "Ada", updatedAt: "2025-06-01" };

_.isEqualWith(left, right, ignoreUpdatedAt);
// → true

_.isEqual(left, right);
// → false
Try It Yourself

How It Works

  1. Nested call for key updatedAt returns true.
  2. Other keys return nothing → compared normally.
  3. id and name match → overall true.
  4. Tip. Top-level customizer call may omit key — return undefined there.

Example 4 — undefined vs false

Only return a boolean when you mean to override.

Lodash
function bad(a, b) {
  return typeof a === "number" && typeof b === "number" && a === b;
  // returns false for non-numbers → forces inequality!
}

function good(a, b) {
  if (typeof a === "number" && typeof b === "number") {
    return a === b;
  }
  // undefined → default deep compare
}

_.isEqualWith({ x: 1 }, { x: 1 }, bad);
// → false  (objects hit customizer first → false)

_.isEqualWith({ x: 1 }, { x: 1 }, good);
// → true
Try It Yourself

How It Works

  1. Customizer runs on the whole objects first.
  2. bad returns false for objects → stops as unequal.
  3. good returns undefined for objects → deep walk continues.
  4. Rule. Prefer early if + no return over a boolean expression for every pair.

Example 5 — Number Tolerance

Treat floats as equal when within a small epsilon.

Lodash
function near(a, b) {
  if (typeof a === "number" && typeof b === "number") {
    return Math.abs(a - b) < 0.01;
  }
}

_.isEqualWith({ score: 0.1 + 0.2 }, { score: 0.3 }, near);
// → true

_.isEqual({ score: 0.1 + 0.2 }, { score: 0.3 });
// → false
Try It Yourself

How It Works

  1. 0.1 + 0.2 is not exactly 0.3 in IEEE floats.
  2. near accepts a tiny difference for number pairs.
  3. Object shell returns undefined → nested walk applies near to score.
  4. Use case. Tests and UI state where float noise is expected.

Browser & Runtime Support

_.isEqualWith is a Lodash Lang 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+

_.isEqualWith()

Available in [email protected] full builds and the lodash/isEqualWith 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
_.isEqualWith Lodash 4.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import isEqualWith from "lodash/isEqualWith". Use plain isEqual when you do not need a customizer.

Frequently Asked Questions

Like _.isEqual, but you pass a customizer. If it returns undefined, Lodash handles that pair with default deep equality. Any other return is coerced to a boolean.
Return undefined for pairs you want Lodash to compare normally (including nested recursion). Return true or false only when you want to override the result.
Up to six: (objValue, othValue [, index|key, object, other, stack]). Nested walks may include key/index and parent objects.
_.isEqual uses Lodash defaults only. _.isEqualWith lets you treat some values as equal (or force unequal) before the default logic runs.
Lodash 4.0.0. Prefer import isEqualWith from "lodash/isEqualWith" for tree-shaking.
Yes — isMatchWith is the partial-match cousin. Use isEqualWith for full deep equality with custom rules.

Next: _.isError()

Check whether a value is an Error object.

_.isError() 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