Underscore.js _.value() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Chaining

Definition

Extracts the value of a wrapped object (official Underscore docs). Written as _.chain(obj).value(). Stable chaining helper — not deprecated.

Pass the required arguments shown below. Chained steps keep returning wrappers until you call .value() for the plain result.

Syntax

Call _.value. Start with this line.

Underscore
_.chain(obj).value()
CallWhat it does
_.chain(obj).value()Primary signature.
_.value(...)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
_.chain(obj).value()

Parameters

ParameterDescription
Wrapped objectRequired. From _.chain or _
.value()Required. Returns _wrapped (plain value)

Return Value

Return ValueDescription
*The value returned by _.value().

Underscore.js Examples

Example 1 — Official Docs Unwrap

Reverse a list inside a chain, then extract the plain array.

Underscore
_.chain([1, 2, 3]).reverse().value();
// → [3, 2, 1]
Try It Yourself

How It Works

  1. Wrap. _.chain([1, 2, 3]) creates a wrapper.
  2. Reverse. Proxied reverse flips the wrapped array (and mutates the original).
  3. Unwrap. .value() returns the plain [3, 2, 1].
  4. Docs sample. This is the official Underscore unwrap example.

Example 2 — Wrapper Until .value()

Without .value() you still have a wrapper, not an array.

Underscore
var wrapped = _.chain([1, 2, 3]).map(function (n) {
  return n * 2;
});

Array.isArray(wrapped);   // false
typeof wrapped.value;     // "function"
wrapped.value();          // [2, 4, 6]
Try It Yourself

How It Works

  1. Still wrapped. After map, Underscore returns another wrapper.
  2. Not an array. Array.isArray(wrapped) is false.
  3. Extract. .value() reads _wrapped → [2, 4, 6].
  4. Rule. Treat a missing .value() as an unfinished chain.

Example 3 — toJSON and valueOf

Both aliases call the same unwrap function as .value().

Underscore
var wrapped = _.chain([1, 2, 3]).map(function (n) {
  return n * 10;
});

wrapped.value();                 // [10, 20, 30]
wrapped.valueOf();               // [10, 20, 30]
JSON.stringify(wrapped);         // "[10,20,30]"  (uses toJSON)
Try It Yourself

How It Works

  1. Same function. Underscore assigns valueOf and toJSON to value.
  2. JSON.stringify. Calls toJSON, so it serializes the inner array.
  3. Prefer .value() in app code — clearest intent.
  4. Aliases help engines unwrap during coercion and serialization.

Example 4 — Unwrap a Stooges Pipeline

End the official chain sample with .value() to get a plain string.

Underscore
var stooges = [
  { name: "curly", age: 25 },
  { name: "moe", age: 21 },
  { name: "larry", age: 23 }
];

_.chain(stooges)
  .sortBy(function (s) { return s.age; })
  .map(function (s) { return s.name + " is " + s.age; })
  .first()
  .value();
// → "moe is 21"
Try It Yourself

How It Works

  1. Pipeline. Sort, map sentences, take the first — still wrapped.
  2. Unwrap. .value() yields the string "moe is 21".
  3. Pair with chain. See the _.chain() tutorial for the full walkthrough.
  4. Type. Result can be any plain value — not only arrays.

Browser & Runtime Support

.value() ships with Underscore.js (1.x) on the chain wrapper prototype. It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.chain(obj).value()

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
.value() Underscore 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

On a wrapped Underscore object, .value() extracts the inner value. The official form is _.chain(obj).value(). Example: _.chain([1, 2, 3]).reverse().value() returns [3, 2, 1].
No. _.value is not a function on the Underscore namespace. Call .value() on the object returned by _.chain(obj) or _(obj).
Chained methods keep returning wrappers. .value() gives you the plain array, object, string, or number. Skip it and you still have a wrapper.
Yes. Underscore sets .valueOf and .toJSON to the same function as .value, so arithmetic and JSON.stringify can unwrap automatically.
No. It returns the current _wrapped reference. If a prior step mutated that value (for example reverse), you get that mutated result.
No. It is a stable Underscore prototype method and still shown in the official docs.

Back to Underscore.js

Explore more Underscore helpers — arrays, collections, objects, and utilities.

Underscore.js hub →

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