Underscore.js _.property() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns a function that will itself return the key property of any passed-in object. path may be a simple key, or an array of keys/indexes for deep fetching (official Underscore docs). Stable helper — not deprecated.

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.property. Start with this line.

Underscore
_.property(path)
CallWhat it does
_.property(path)Primary signature.
_.property(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.property(path)

Parameters

ParameterDescription
pathRequired. String key, or array of keys/indexes

Return Value

Return ValueDescription
*Function (object) → value

Underscore.js Examples

Example 1 — Official: Read name

Build an accessor for "name", then call it on an object.

Underscore
var stooge = {name: "moe"};
_.property("name")(stooge);
// → "moe"
Try It Yourself

How It Works

  1. Path. "name" is a shallow string key.
  2. Build. _.property returns a getter function.
  3. Call. Pass stooge; it reads stooge.name.
  4. Official result. "moe".

Example 2 — Deep Path with an Array

Walk nested keys and an array index in one accessor.

Underscore
var stooges = {moe: {hobbies: ["curling", "follies"]}};

_.property(["moe", "hobbies", 1])(stooges);
// → "follies"
Try It Yourself

How It Works

  1. Path array. Segments: moe → hobbies → index 1.
  2. Walk. Each segment drills one level deeper.
  3. Index. 1 selects the second hobby string.
  4. Result. "follies" — same pattern as the docs deep path.

Example 3 — Pluck Names with _.map

Pass the accessor to a collection helper to pull one field from many objects.

Underscore
var people = [
  {name: "moe", age: 40},
  {name: "larry", age: 50},
  {name: "curly", age: 60}
];

_.map(people, _.property("name"));
// → ["moe", "larry", "curly"]

// Same idea as _.pluck(people, "name")
Try It Yourself

How It Works

  1. Accessor. _.property("name") reads .name on each item.
  2. map. Runs that function once per person.
  3. Result. An array of name strings.
  4. Shortcut. _.pluck does the same for a single key.

Example 4 — _.property vs _.propertyOf

Same read; opposite arguments fixed first.

Underscore
var stooge = {name: "moe", age: 50};

_.property("name")(stooge);      // → "moe"
_.propertyOf(stooge)("name");    // → "moe"

// property:   fix key, wait for object
// propertyOf: fix object, wait for key
Try It Yourself

How It Works

  1. property. Path first — best when many objects share one key.
  2. propertyOf. Object first — best when one object, many keys — see _.propertyOf.
  3. Same value. Both return "moe" here.
  4. Pick. Choose based on which argument you reuse.

Browser & Runtime Support

_.property ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. Deep array paths are Underscore’s portable alternative to ad-hoc nested reads.

✓ Stable · Underscore 1.x

_.property()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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
_.property Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API by itself — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.property(path) returns a function. Call that function with an object and it returns the value at path. Official example: _.property('name')({name: 'moe'}) returns 'moe'.
Pass an array path, e.g. _.property(['moe', 'hobbies', 1]). Underscore walks one segment at a time. A plain string is a shallow key.
The accessor returns undefined. For array paths, null/undefined midway stops safely without throwing.
Inverses. _.property(key) fixes the key and waits for an object. _.propertyOf(obj) fixes the object and waits for a key.
_.property returns a reusable function with no default. _.get(object, path, [default]) reads immediately and can supply a fallback.
No. It is a stable Underscore object helper and powers string iteratee shorthand in many collection methods. Load Underscore 1.x and call _.property(path).

Next: _.propertyOf()

Fix one object and create a function that reads any key from it.

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