Underscore.js _.values() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns all of the values of the object’s own properties (official Underscore docs). Stable Object 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 _.values. Start with this line.

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

Parameters

ParameterDescription
objectRequired. Source whose own values you want

Return Value

Return ValueDescription
*New array of property values

Underscore.js Examples

Example 1 — Official Object Values

Return every own enumerable value as a plain array.

Underscore
_.values({ one: 1, two: 2, three: 3 });
// → [1, 2, 3]
Try It Yourself

How It Works

  1. Read own keys. Underscore gets ["one","two","three"].
  2. Lookup each. Pull 1, then 2, then 3.
  3. Return array. A new list you can map or reduce.
  4. Object untouched. Only a new array is created.

Example 2 — Values Align with Keys

_.keys and _.values share the same order — pair them by index.

Underscore
var user = { name: "Mari", role: "admin", active: true };

var keys = _.keys(user);      // ["name", "role", "active"]
var vals = _.values(user);    // ["Mari", "admin", true]

// keys[0] → "name",  vals[0] → "Mari"
// keys[1] → "role",  vals[1] → "admin"
Try It Yourself

How It Works

  1. Same walk. Both helpers use the object’s own key order.
  2. Index match. Position i in keys matches position i in values.
  3. Mixed types. Values can be strings, booleans, numbers, objects, …
  4. Need pairs? Prefer _.pairs for [key, value] tuples.

Example 3 — Own Values Only

Inherited prototype properties do not appear in the result.

Underscore
function Person(name) {
  this.name = name;
}
Person.prototype.kind = "human";

var p = new Person("Ada");

_.values(p);
// → ["Ada"]   // "human" is inherited — skipped

_.allKeys(p);
// → ["name", "kind"]  // allKeys sees inherited names
Try It Yourself

How It Works

  1. Own field. name is set on the instance → included.
  2. Prototype field. kind lives on Person.prototype → skipped by _.values.
  3. Contrast. _.allKeys lists inherited names; values still only owns.
  4. Rule. Need only instance data? _.values is the right tool.

Example 4 — Empty Object & Null

Empty objects and non-objects yield an empty array — no throw.

Underscore
_.values({});           // → []
_.values(null);         // → []
_.values(undefined);    // → []
_.values(42);           // → []
Try It Yourself

How It Works

  1. Empty object. No own keys → empty values array.
  2. Nullish. _.keys returns [], so values does too.
  3. Primitives. Numbers/booleans have no own enumerable props here → [].
  4. vs native. Object.values(null) throws; Underscore stays safe.

Browser & Runtime Support

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

_.values()

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
_.values 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]). Native Object.values() needs ES2017+.

Frequently Asked Questions

_.values(object) returns an array of the object's own enumerable property values. Example: _.values({one: 1, two: 2, three: 3}) returns [1, 2, 3].
No. It only collects values from the object's own enumerable properties — prototype-chain properties are skipped.
_.keys() returns property names; _.values() returns the matching values. They share the same order, so keys[i] pairs with values[i].
For plain objects they are nearly the same. _.values() goes through _.keys and returns [] for null/undefined instead of throwing. On modern engines, Object.values() is a fine native alternative.
Modern Underscore returns []. Non-objects have no own enumerable properties to list (and null/undefined are guarded).
Order matches _.keys() / the engine's own enumerable string-key order. In practice that is insertion order, but do not rely on order for correctness.

Next: _.pairs()

Turn an object into an array of [key, value] pairs — great when you need both sides together.

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