Lodash _.property() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a function that returns the value at path of a given object — a reusable path getter. Part of Lodash Util since 2.4.0 (stable — not deprecated).

Note: Collection methods already accept property shorthands (_.map(arr, 'a.b')). Use _.property when you need an explicit, reusable accessor.

Syntax

Call _.property. Start with this line.

Lodash
_.property(path)
CallWhat it does
_.property(path)Primary signature.
_.property(...)Call the util helper.

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

Library declarations
Lodash
_.property(path)

Parameters

ParameterDescription
pathRequired. String or array path to read

Return Value

Return ValueDescription
*Getter (object) → value

Lodash Examples

Example 1 — Official: Map with Dot Path

Pluck the same nested field from every object.

Lodash
var objects = [
  { 'a': { 'b': 2 } },
  { 'a': { 'b': 1 } }
];

_.map(objects, _.property('a.b'));
// → [2, 1]
Try It Yourself

How It Works

  1. Path. 'a.b' means nested key b under a.
  2. Getter. _.property('a.b') returns a function that reads that path.
  3. Map. Runs the getter on each object.
  4. Result. [2, 1] — the plucked values.

Example 2 — Official: sortBy with Path Array

Sort by a nested path, then map the sorted values.

Lodash
var objects = [
  { 'a': { 'b': 2 } },
  { 'a': { 'b': 1 } }
];

_.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
// → [1, 2]
Try It Yourself

How It Works

  1. Array path. ['a', 'b'] is the same nested field as 'a.b'.
  2. Sort. _.sortBy orders by that getter → smaller b first.
  3. Map. Pluck 'a.b' from the sorted list.
  4. Result. [1, 2] — ascending nested values.

Example 3 — String Shorthand (No Wrap)

Collection methods already treat property strings as getters.

Lodash
var objects = [
  { 'a': { 'b': 2 } },
  { 'a': { 'b': 1 } }
];

_.map(objects, 'a.b');
// → [2, 1]

_.map(objects, _.property('a.b'));
// → [2, 1]  // same result
Try It Yourself

How It Works

  1. Shorthand. _.map(objects, 'a.b') is enough for everyday use.
  2. Under the hood. Lodash converts via _.iteratee → property.
  3. Explicit. Wrap with _.property when you reuse the getter.
  4. Same rules. Both paths read nested a.b.

Example 4 — Missing Path

Absent paths return undefined — no error.

Lodash
var getZ = _.property('a.z');

getZ({ a: { b: 2 } });
// → undefined

_.get({ a: { b: 2 } }, 'a.z', 0);
// → 0  // default via _.get
Try It Yourself

How It Works

  1. Missing key. a.z does not exist → undefined.
  2. Safe. No throw for bad paths.
  3. Default. Prefer _.get when you need a fallback in one call.
  4. Reuse. Keep _.property when the getter itself is what you pass around.

Example 5 — property vs method

One reads the value; the other calls it if it is a function.

Lodash
var objects = [
  { a: { b: _.constant(2) } },
  { a: { b: _.constant(1) } }
];

_.map(objects, _.property('a.b'));
// → [ƒ, ƒ]   // returns the functions

_.map(objects, _.method('a.b'));
// → [2, 1]   // calls the functions
Try It Yourself

How It Works

  1. property. Resolves the path and returns whatever is there (functions).
  2. method. Resolves the path and invokes it → numbers.
  3. Rule. Pluck → property. Call → method.
  4. Output note. The demo prints "function" for clarity in text.

Browser & Runtime Support

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

✓ Stable · Lodash 2.4.0+

_.property()

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

100% With Lodash 2.4+
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
_.property Lodash 2.4.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import property from "lodash/property" for smaller bundles. Collection methods already accept path-string shorthands with the same rules.

Frequently Asked Questions

_.property(path) returns a getter function. Pass an object to that getter and it returns the value at path—same resolution rules as _.get.
A string like 'a.b' or an array of keys like ['a', 'b']. Both forms work with nested objects.
_.get(object, path) reads once. _.property(path) returns a reusable function you can pass to _.map, _.sortBy, or store for later.
Usually no. _.map(objects, 'a.b') already uses the property iteratee shorthand. Wrap with _.property when you want an explicit, reusable getter.
_.property reads the value at the path. _.method calls the value if it is a function. Use property to pluck; use method to invoke.
The getter returns undefined. It does not throw. Use _.get(object, path, defaultValue) when you need a fallback in one call.

Next: _.propertyOf()

Create a getter bound to one object — supply the path later.

_.propertyOf() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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