Underscore.js _.propertyOf() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Takes an object and returns a function which will return the value of a provided property from that object — the inverse of _.property (official Underscore docs). Stable helper — not deprecated. Read-only; does not mutate the source.

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

Syntax

Call _.propertyOf. Start with this line.

Underscore
_.propertyOf(object)
CallWhat it does
_.propertyOf(object)Primary signature.
_.propertyOf(...)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
_.propertyOf(object)

Parameters

ParameterDescription
objectRequired. Source fixed inside the returned function
Path argOptional. String key, or array of keys/indexes

Return Value

Return ValueDescription
*Function (path) → value

Underscore.js Examples

Example 1 — Official: Read name

Fix the object, then pass the key to the returned function.

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

How It Works

  1. Object first. stooge is closed over by the lookup.
  2. Build. _.propertyOf returns a function waiting for a key.
  3. Call. Pass "name"; it reads stooge.name.
  4. Official result. "moe".

Example 2 — Look Up Several Keys

Reuse one lookup across a list of property names.

Underscore
var stooge = {name: "moe", age: 50, userid: "moe1"};
var lookup = _.propertyOf(stooge);

_.map(["name", "age", "userid"], lookup);
// → ["moe", 50, "moe1"]
Try It Yourself

How It Works

  1. One object. lookup always reads from stooge.
  2. Many keys. _.map passes each string to lookup.
  3. Result. Values in the same order as the key list.
  4. Pattern. Ideal when the object is fixed and keys vary.

Example 3 — Deep Path with an Array

Pass an array path to walk nested keys and indexes.

Underscore
var data = {moe: {hobbies: ["curling", "follies"]}};
var lookup = _.propertyOf(data);

lookup(["moe", "hobbies", 1]);
// → "follies"
Try It Yourself

How It Works

  1. Fixed root. lookup always starts at data.
  2. Path array. Segments: moe → hobbies → index 1.
  3. Walk. Each segment drills one level deeper.
  4. Result. "follies" — same deep-path idea as _.property.

Example 4 — _.propertyOf vs _.property

Same read; opposite arguments fixed first.

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

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

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

How It Works

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

Browser & Runtime Support

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

✓ Stable · Underscore 1.x

_.propertyOf()

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

_.propertyOf(object) returns a function. Call that function with a key (or array path) and it returns the value from the fixed object. Official example: _.propertyOf({name: 'moe'})('name') returns 'moe'.
They are inverses. _.property(key) fixes the key and waits for an object. _.propertyOf(obj) fixes the object and waits for a key. Same value, opposite argument order.
Yes. Pass an array path to the returned function, e.g. lookup(['user', 'city']). A plain string is a shallow key.
Missing keys return undefined. A null/undefined object yields a safe accessor that returns undefined instead of throwing.
Use _.propertyOf when you will look up several keys on the same object. Use _.get for one immediate read, especially with a default fallback.
No. It is a stable Underscore object helper. Load Underscore 1.x and call _.propertyOf(object).

Next: _.matcher()

Build a reusable predicate that checks key/value pairs on an object.

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