Lodash _.values() Method

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 6 Examples + 3 Try It
Object utilities

What You’ll Learn

By the end of this tutorial, you’ll use _.values() to pull property values into an array for summing, filtering, charting, and Lodash pipelines.

01

Core syntax

_.values(object) returns a values array.

02

Non-mutating

Reads the object; original stays unchanged.

03

Own values only

Own enumerable string-keyed properties.

04

Aggregate easily

Pair with _.sum, _.mean, or _.max.

05

vs Object.values

Compare with native Object.values().

06

Pair with keys

Complement _.keys() and _.toPairs().

What Is _.values()?

_.values() walks a plain object and returns an array containing each own enumerable property value—without the keys. It is Lodash’s version of Object.values() and the value-side counterpart to _.keys().

💡
Values as arrays unlock array utilities

Once you have a values array, you can sum, filter, map, or pass it into charts—without manually looping with for...in.

Use it when totaling sales by product, averaging ages from a lookup object, feeding chart libraries, or piping object data through Lodash chains where you only care about the values, not the keys.

📝 Syntax

The signature takes one argument—the object whose values you want:

javascript
_.values(object)

Syntax Rules

  • object — any object (or object-like value Lodash accepts).
  • Return value — array of property values in enumeration order.
  • Included values — from own enumerable string-keyed properties only.
  • Excluded — symbol keys, non-enumerable props, and inherited prototype values.
  • Null-safe — returns [] for null or undefined (unlike Object.values()).
javascript
import values from "lodash/values";

const myObject = { a: 1, b: 2, c: 3 };
const valueArray = values(myObject);

// valueArray -> [1, 2, 3]

⚡ Quick Reference

TaskCode patternResult
Basic extraction_.values({ a: 1, b: 2 })[1, 2]
Sum numeric values_.sum(_.values(obj))Total of all values
Iterate values_.values(obj).forEach(...)Array iteration
Get property names_.keys(obj)Complement: keys only
Native equivalentObject.values(obj)Same for plain objects
Inherited values_.valuesIn(obj)See _.valuesIn()
Mutates?
No

Returns new array

Keys
Own

Enumerable strings

Returns
value[]

Values only

Null-safe
[]

For null/undefined

🧰 Parameters

The single argument to _.values() and what comes back:

object Required

The source object whose own enumerable string-keyed property values are collected.

_.values({ name: "Ada", age: 36 })
return value Output

Array of property values in the same enumeration order as _.keys().

["Ada", 36]
own values Scope

Only values from properties on the object itself—not inherited prototype values (use _.valuesIn for those).

obj.hasOwnProperty("key")
nested values Behavior

Nested objects appear as single elements in the array—they are not recursively flattened.

[{ nested: 1 }, 2]

Symbol-keyed properties are excluded. For null or undefined, Lodash returns [] instead of throwing.

Examples Gallery

Practical _.values() patterns with sample output and interactive Try It Yourself labs.

📚 Getting Started

Extract property values from plain objects into arrays.

Example 1 — Basic object values

Collect all own enumerable values from a simple object.

javascript
const sampleObject = { a: 1, b: 2, c: 3 };
const objectValues = _.values(sampleObject);

console.log(objectValues);
// -> [1, 2, 3]
Try It Yourself

How It Works

Each own enumerable string key contributes its current value to the result array—keys are omitted.

Example 2 — Sum numeric values with _.sum()

Total sales across products by passing _.values() into _.sum().

javascript
const salesData = {
  product1: 100,
  product2: 200,
  product3: 150
};

const totalSales = _.sum(_.values(salesData));

console.log(totalSales);
// -> 450
Try It Yourself

📈 Practical Patterns

Own vs inherited values, iteration, aggregation, and native alternatives.

Example 3 — Class instance (own values only)

_.values() skips inherited prototype properties—only own instance values are returned.

javascript
function SampleClass() {
  this.a = 1;
  this.b = 2;
}

SampleClass.prototype.c = 3;

const instance = new SampleClass();
const instanceValues = _.values(instance);

console.log(instanceValues);
// -> [1, 2]  (prototype c is excluded)
Try It Yourself

Example 4 — Iterate values with forEach

Loop over property values directly after converting to an array.

javascript
const scores = { math: 92, science: 88, english: 95 };

_.values(scores).forEach(function (score) {
  console.log("Score: " + score);
});
// Score: 92
// Score: 88
// Score: 95

Example 5 — Average ages with mapValues and mean

Extract nested ages into a flat object, then average with _.mean(_.values(...)).

javascript
const userData = {
  user1: { name: "Alice", age: 30 },
  user2: { name: "Bob", age: 25 },
  user3: { name: "Charlie", age: 35 }
};

const userAges = _.mapValues(userData, function (user) {
  return user.age;
});
const averageAge = _.mean(_.values(userAges));

console.log(averageAge);
// -> 30

🚀 Beyond the Basics

Native alternatives and null-safe behavior.

Example 6 — _.values() vs Object.values()

For plain objects both return the same values; Lodash also handles null safely.

javascript
const obj = { a: 1, b: 2 };

const lodashValues = _.values(obj);
const nativeValues = Object.values(obj);

console.log(JSON.stringify(lodashValues) === JSON.stringify(nativeValues));
// -> true

console.log(_.values(null));
// -> []  (Object.values(null) throws TypeError)

🧠 How _.values() Works

1

Enumerate keys

Lodash collects own enumerable string-keyed property names from the object.

Input
2

Read values

Each key is used to read the current property value from the object.

Collect
3

Return array

A new array of values is returned; the original object is untouched.

Output
=

Ready to aggregate

Pass the values array to _.sum, _.mean, _.max, or any array utility.

📝 Notes

  • _.values() does not mutate the source object—it returns a new array.
  • Only own enumerable string-keyed property values are included.
  • Nested object values are not flattened—each nested object is one array element.
  • Value order matches _.keys() enumeration order for the same object.
  • For inherited enumerable values, use _.valuesIn().
  • For property names instead of values, use _.keys() or _.toPairs() when you need both.

Conclusion

_.values() turns object property values into a plain array, making summing, averaging, filtering, and charting straightforward. Pair it with _.keys() when you need names and values separately, or _.toPairs() when you need both together.

For plain objects in modern JavaScript, Object.values() is equivalent—choose Lodash when you want null-safe behavior or consistency in a Lodash pipeline. Next in the series: _.valuesIn() for inherited property values.

💡 Best Practices

✅ Do

  • Use _.values when you only need values, not keys
  • Combine with _.sum, _.mean, or _.max for numeric objects
  • Prefer _.values over Object.values when input may be null
  • Pair with _.keys when you need parallel key/value arrays
  • Use _.toPairs when you need both key and value in each iteration

❌ Don’t

  • Expect _.values to flatten nested objects recursively
  • Assume symbol keys or non-enumerable props are included
  • Use _.values when you need inherited prototype values (use _.valuesIn)
  • Sum values without confirming they are all numbers
  • Confuse _.values with _.mapValues—the latter transforms and returns a new object

Key Takeaways

Knowledge Unlocked

Five things to remember about _.values()

Use these when extracting property values into arrays.

5
Core concepts
📦 02

Non-mutating

New array.

Important
🗃️ 03

Own values

Enumerable strings.

Scope
🔀 04

Aggregate

sum, mean, max.

Pattern
🛠️ 05

Null-safe

[] for null.

Compare

❓ Frequently Asked Questions

_.values() collects the values of an object's own enumerable string-keyed properties into a new array. Keys are not included—only the property values, in enumeration order.
No. _.values() reads the object and returns a new array. The source object is unchanged.
No. Only own enumerable properties on the object itself are included. Use _.valuesIn() when you also need inherited enumerable values.
For plain objects they return the same values in modern JavaScript. _.values() is null-safe—it returns [] for null or undefined instead of throwing a TypeError like Object.values().
_.keys() returns property names; _.values() returns property values. Both cover the same own enumerable string keys, so _.keys(obj).length === _.values(obj).length.
Yes. Pass the array to _.sum(), _.mean(), or other array utilities—for example _.sum(_.values(salesData)) totals all numeric values in an object.
Did you know?

_.values() is the value-side twin of _.keys()—both cover the same own enumerable properties, but one returns names and the other returns values. Unlike Object.values(), Lodash returns an empty array for null or undefined, which makes it safer in pipelines where the input might be missing.

Practice _.values() in the Live Editor

Extract object values, sum numeric data, and compare with native APIs instantly.

Open Try It editor →

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.

6 people found this page helpful