Lodash _.propertyOf() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

The opposite of _.property: creates a function that returns the value at a given path of a fixed object. Part of Lodash Util since 3.0.0 (stable — not deprecated).

Note: The object is fixed; the path is supplied later — ideal for _.map over a list of paths against one target.

Syntax

Call _.propertyOf. Start with this line.

Lodash
_.propertyOf(object)
CallWhat it does
_.propertyOf(object)Primary signature.
_.propertyOf(...)Call the util helper.

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

Library declarations
Lodash
_.propertyOf(object)

Parameters

ParameterDescription
objectRequired. Object to read from

Return Value

Return ValueDescription
*Accessor (path) → value

Lodash Examples

Example 1 — Official: Map String Paths

Read several paths from one shared object.

Lodash
var array = [0, 1, 2],
    object = { 'a': array, 'b': array, 'c': array };

_.map(['a[2]', 'c[0]'], _.propertyOf(object));
// → [2, 0]
Try It Yourself

How It Works

  1. Shared array. Keys a, b, c all point at [0, 1, 2].
  2. Accessor. _.propertyOf(object) fixes the object; paths arrive later.
  3. Map. Each path string is read from that object.
  4. Result. 'a[2]' → 2, 'c[0]' → 0.

Example 2 — Official: Path Arrays

Same results with array paths instead of bracket strings.

Lodash
var array = [0, 1, 2],
    object = { 'a': array, 'b': array, 'c': array };

_.map([['a', '2'], ['c', '0']], _.propertyOf(object));
// → [2, 0]
Try It Yourself

How It Works

  1. Array path. ['a', '2'] resolves like 'a[2]'.
  2. Same accessor. Still reads from the fixed object.
  3. Result. Identical output: [2, 0].
  4. Pick a style. Arrays help when keys are dynamic or numeric.

Example 3 — Call the Accessor Directly

You do not need _.map — pass one path to the returned function.

Lodash
var array = [0, 1, 2],
    object = { 'a': array, 'c': array };

var get = _.propertyOf(object);
get('a[2]');
// → 2

_.get(object, 'c[0]');
// → 0  // one-shot form
Try It Yourself

How It Works

  1. Factory. Build an accessor once with _.propertyOf.
  2. Call. Pass a single path → value is read.
  3. Compare. _.get is the one-shot equivalent.
  4. Choose. Many paths → propertyOf; one read → get.

Example 4 — Missing Path

Absent paths return undefined — no error.

Lodash
var object = { a: [0, 1, 2] };
var get = _.propertyOf(object);

get('a[9]');
// → undefined

_.get(object, 'a[9]', -1);
// → -1  // default via _.get
Try It Yourself

How It Works

  1. Out of range. a[9] 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 propertyOf when the accessor itself is what you pass around.

Example 5 — propertyOf vs property

Same read, opposite binding order.

Lodash
var array = [0, 1, 2],
    object = { 'a': array };

_.propertyOf(object)('a[2]');
// → 2

_.property('a[2]')(object);
// → 2  // same result, path fixed first
Try It Yourself

How It Works

  1. propertyOf. Object first → pass path later.
  2. property. Path first → pass object later.
  3. Same read. Both return object.a[2] → 2.
  4. Rule. Many paths / one object → propertyOf; many objects / one path → property.

Browser & Runtime Support

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

✓ Stable · Lodash 3.0.0+

_.propertyOf()

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

100% With Lodash 3.0+
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
_.propertyOf Lodash 3.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import propertyOf from "lodash/propertyOf" for smaller bundles. Pair with _.map when you have many paths on one object.

Frequently Asked Questions

_.propertyOf(object) returns a function that takes a path and returns the value at that path on the fixed object. It is the opposite of _.property.
A path (string or array)—not the object. Example: _.propertyOf(object)('a[2]') reads object.a[2].
_.property(path) fixes the path—the object comes later. _.propertyOf(object) fixes the object—the path comes later.
_.get(object, path) reads once. _.propertyOf(object) returns a reusable path reader for many paths on the same object.
Yes. That is the official pattern: _.map(['a[2]', 'c[0]'], _.propertyOf(object)) reads each path from one object.
The accessor returns undefined. It does not throw. Use _.get(object, path, defaultValue) when you need a fallback in one call.

Next: _.range()

Create an array of numbers progressing from start up to, but not including, end.

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