Lodash _.matchesProperty() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a predicate that compares the value at a path on an object to a fixed srcValue — true when they are equivalent (deep compare). Part of Lodash Util since 3.2.0 (stable — not deprecated).

Note: The iteratee shorthand is a two-element array [path, value] — same rules as calling _.matchesProperty(path, value).

Syntax

Call _.matchesProperty. Start with this line.

Lodash
_.matchesProperty(path, srcValue)
CallWhat it does
_.matchesProperty(path, srcValue)Primary signature.
_.matchesProperty(...)Call the util helper.

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

Library declarations
Lodash
_.matchesProperty(path, srcValue)

Parameters

ParameterDescription
pathRequired. String or array path to read
srcValueRequired. Value to compare at that path

Return Value

Return ValueDescription
*Predicate (object) → boolean

Lodash Examples

Example 1 — Official: Find by Path Value

Find the first object whose path equals the expected value.

Lodash
var objects = [
  { 'a': 1, 'b': 2, 'c': 3 },
  { 'a': 4, 'b': 5, 'c': 6 }
];

_.find(objects, _.matchesProperty('a', 4));
// → { 'a': 4, 'b': 5, 'c': 6 }
Try It Yourself

How It Works

  1. Predicate. _.matchesProperty('a', 4) means “path a equals 4.”
  2. First row. a is 1 → skip.
  3. Second row. a is 4 → match.
  4. Find. Returns that object (not an array).

Example 2 — Array Shorthand [path, value]

Collection methods accept the two-element array form directly.

Lodash
var objects = [
  { 'a': 1, 'b': 2, 'c': 3 },
  { 'a': 4, 'b': 5, 'c': 6 }
];

_.find(objects, ['a', 4]);
// → { 'a': 4, 'b': 5, 'c': 6 }

_.find(objects, _.matchesProperty('a', 4));
// → same result
Try It Yourself

How It Works

  1. Shorthand. ['a', 4] is the iteratee form of path + value.
  2. Convert. Lodash turns it into _.matchesProperty('a', 4).
  3. Same result. Explicit wrap is optional for everyday find/filter.
  4. When to wrap. Reuse the predicate, or pass it outside Lodash APIs.

Example 3 — Nested Path

Use a dot path or path array for nested fields.

Lodash
var users = [
  { user: { name: 'barney', active: true } },
  { user: { name: 'fred',   active: false } }
];

_.find(users, _.matchesProperty('user.name', 'fred'));
// → { user: { name: 'fred', active: false } }

_.find(users, _.matchesProperty(['user', 'active'], false));
// → same object
Try It Yourself

How It Works

  1. Dot path. 'user.name' reads the nested name.
  2. Array path. ['user','active'] is equivalent style for keys.
  3. Compare. Deep equality against srcValue.
  4. Use. Ideal for one nested field without a full _.matches object.

Example 4 — Empty srcValue

Official note: empty {} / [] match any object / array at that path.

Lodash
var hasAnyMeta = _.matchesProperty('meta', {});

hasAnyMeta({ meta: { x: 1 } });
// → true

hasAnyMeta({ meta: {} });
// → true

hasAnyMeta({ meta: null });
// → false
Try It Yourself

How It Works

  1. Empty object. {} as srcValue means “any object here.”
  2. Filled / empty. Both object values pass.
  3. Not an object. null fails.
  4. Warning. Easy to over-match if you pass empty nests by accident.

Example 5 — Official: Several Possible Values

Combine matchers with _.overSome for OR-style path checks.

Lodash
var objects = [
  { 'a': 1, 'b': 2, 'c': 3 },
  { 'a': 4, 'b': 5, 'c': 6 }
];

_.filter(objects, _.overSome([
  _.matchesProperty('a', 1),
  _.matchesProperty('a', 4)
]));
// → both objects
Try It Yourself

How It Works

  1. Two values. Match a === 1 or a === 4.
  2. OR helper. _.overSome succeeds if any matcher passes.
  3. Both rows. Each object hits one branch.
  4. Use. Official pattern for several possible values on one path.

Browser & Runtime Support

_.matchesProperty is a Lodash Util helper since 3.2.0. It runs anywhere Lodash 3.2+ / 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.2.0+

_.matchesProperty()

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

100% With Lodash 3.2+
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
_.matchesProperty Lodash 3.2.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import matchesProperty from "lodash/matchesProperty" for smaller bundles. Collection methods already accept [path, value] shorthands with the same rules.

Frequently Asked Questions

_.matchesProperty(path, srcValue) returns a predicate. For each object it reads the value at path (Lodash get-style) and deeply compares it to srcValue. Returns true when they match.
A string like 'a' or 'user.name', or an array of keys like ['user', 'name']. Same path forms as _.get / _.property.
_.matches({ a: 4, c: 6 }) checks multiple keys with a source object. _.matchesProperty('a', 4) checks one path against one value.
_.find(arr, ['a', 4]) uses the same rules as _.find(arr, _.matchesProperty('a', 4)). The two-element array is the iteratee shorthand.
_.property('a') returns a getter that plucks the value. _.matchesProperty('a', 4) returns a predicate that is true only when that value equals 4.
Yes. Official note: empty object and empty array srcValue values match any object or array at that path. Be careful with {} or [] as the expected value.

Next: _.method()

Create a function that invokes a method at a path on a given object.

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

10 people found this page helpful