Lodash _.result() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Like _.get, but if the resolved value is a function, Lodash invokes it (with this = parent) and returns that call’s result. Part of Lodash Object (stable — not deprecated).

Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.

Syntax

Call _.result. Start with this line.

Lodash
_.result(object, path, [defaultValue])
CallWhat it does
_.result(object, path, [defaultValue])Primary signature.
_.result(object)Work with an object’s keys, values, or paths.

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

Library declarations
Lodash
_.result(object, path, [defaultValue])

Parameters

ParameterDescription
objectRequired. Source object
pathRequired. Property path to resolve
defaultValueOptional. Used (or invoked) when path is missing

Return Value

Return ValueDescription
*Resolved value, function result, or default

Lodash Examples

Example 1 — Official: Plain Nested Value

Non-function values are returned as-is.

Lodash
var object = { a: [{ b: { c1: 3, c2: _.constant(4) } }] };

_.result(object, "a[0].b.c1");
// → 3
Try It Yourself

How It Works

  1. Path. Walks a → [0] → b → c1.
  2. Value. Finds the number 3.
  3. No call. Numbers are not functions.
  4. Docs. Matches the official first example.

Example 2 — Official: Invoke a Function at the Path

Functions are called; you get their return value.

Lodash
var object = { a: [{ b: { c1: 3, c2: _.constant(4) } }] };

_.result(object, "a[0].b.c2");
// → 4
Try It Yourself

How It Works

  1. Path. Resolves c2 to a function (_.constant(4)).
  2. Invoke. Lodash calls it with this = parent b.
  3. Return. The function returns 4.
  4. Docs. Matches the official second example.

Example 3 — Official: Default String

Missing paths use the default value.

Lodash
var object = { a: [{ b: { c1: 3, c2: _.constant(4) } }] };

_.result(object, "a[0].b.c3", "default");
// → "default"
Try It Yourself

How It Works

  1. Missing. c3 does not exist.
  2. Fallback. Lodash uses the third argument.
  3. Plain. A string default is returned as-is.
  4. Docs. Matches the official third example.

Example 4 — Official: Default Function

A function default is invoked when the path is missing.

Lodash
var object = { a: [{ b: { c1: 3, c2: _.constant(4) } }] };

_.result(object, "a[0].b.c3", _.constant("default"));
// → "default"
Try It Yourself

How It Works

  1. Missing. Path still resolves to undefined.
  2. Default fn. _.constant('default') is a function.
  3. Invoke. Lodash calls the default and returns 'default'.
  4. Docs. Matches the official fourth example.

Example 5 — result vs get

Same path; different treatment of functions.

Lodash
var object = { a: [{ b: { c2: _.constant(4) } }] };

console.log(_.get(object, "a[0].b.c2"));    // → function
console.log(_.result(object, "a[0].b.c2")); // → 4
Try It Yourself

How It Works

  1. get. Returns the function object itself.
  2. result. Invokes it and returns 4.
  3. When get. You need the function reference later.
  4. When result. You want the computed value at the path.

Browser & Runtime Support

_.result is a Lodash Object helper available in 4.x. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native equivalents combine safe path reads with typeof value === 'function' ? value.call(parent) : value.

✓ Stable · Lodash 4.x

_.result()

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

100% With Lodash 4.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
_.result Lodash 4.x

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import result from "lodash/result" for smaller builds. Use get for raw values; invoke when you need method arguments.

Frequently Asked Questions

_.result(object, path, [defaultValue]) resolves a nested path like _.get. If the resolved value is a function, Lodash invokes it with this bound to its parent object and returns that call’s result.
_.get always returns the value at the path (even if it is a function). _.result calls that function when present. For plain data, both behave the same.
If the path does not resolve, _.result returns defaultValue. If defaultValue is a function, it is invoked and its return value is used.
The function is called with this set to its parent object — the object that owns that property along the path.
Use _.invoke when you need to call a method and pass arguments. _.result invokes zero-arg functions found at a path (or returns non-functions as-is).
Use import result from "lodash/result" or require("lodash/result") for tree-shaking. Full build: import _ from "lodash" then _.result.

Next: _.set()

Set a value at a nested path, creating objects along the way.

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