If the named property is a function, invoke it with the object as context; otherwise return it (official Underscore docs). Built for APIs that allow either a raw value or a function that produces one.
Pass the required arguments shown below. Underscore utility helpers usually return a new value or function — check edge cases before you ship.
Syntax
Read _.result. Start with this line.
Underscore
_.result(object, property, [defaultValue])
Call
What it does
_.result(object, property, [defaultValue])
Primary signature.
_.result(...)
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
_.result(object, property, [defaultValue])
Parameters
Parameter
Description
object
Required. Source to resolve from
property
Required. Key string, or array of keys for nesting
defaultValue
Optional. Used when the resolved value is undefined
Return Value
Return Value
Description
*
Property value, function return, or default
Underscore.js Examples
Example 1 — Official Docs Example
A string property, a function property, and a missing key with a default.
result. Invokes kitchen, then reads cheese → "crumpets".
get. Treats kitchen as a function value — no child keys.
When to use result. Path may include methods you want called.
When to use get. You only want to read, never invoke.
Compatibility
Browser & Runtime Support
_.result 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
_.result()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded. Added in 1.3.3; defaultValue in 1.8.0.
100%With Underscore 1.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.resultUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.result(object, property, [defaultValue]) reads a property. If the value is a function, Underscore invokes it with the object as this and returns that result. If the property is missing or undefined, the optional default is used. If the default is a function, it is invoked too.
var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }}; then _.result(object, 'cheese') is 'crumpets', _.result(object, 'stuff') is 'nonsense', and _.result(object, 'meat', 'ham') is 'ham'.
When the resolved value is undefined — the key is missing, or it is explicitly undefined. null, false, 0, and '' are kept. If defaultValue is a function, Underscore calls it with the parent object as this.
_.get returns whatever sits at the path, including a function you did not call. _.result invokes functions it finds, including along a deep array path. That is why the docs mention APIs that allow either functions or raw properties.
Yes, pass an array of keys such as ['kitchen', 'cheese']. A string is wrapped as a single key, so 'kitchen.cheese' looks up a key with a dot in the name, not a nested path, unless you override _.toPath.
No. It is a stable Underscore utility added in version 1.3.3 (April 2012). Version 1.8.0 added the optional fallback value or function.