Lodash _.valuesIn() 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 _.valuesIn() to collect own and inherited enumerable property values into an array for inspection and debugging.

01

Core syntax

_.valuesIn(object) returns a values array.

02

Inherited values

Includes prototype enumerable properties.

03

vs values

Own-only vs full prototype chain.

04

Non-mutating

Returns a new array.

05

Inspection

Debug class instances and prototypes.

06

When to skip

Prefer _.values() for plain data.

What Is _.valuesIn()?

_.valuesIn() is like _.values(), but it walks the prototype chain and includes inherited enumerable property values too. Think of it as turning a for...in loop into an array of values—keys are omitted.

💡
Own vs inherited

On a class instance, _.values() might return only ["John", 30], while _.valuesIn() also includes enumerable prototype methods like sayHello.

Use it for object inspection, debugging prototype-augmented instances, and understanding what enumerable values exist beyond own properties. For API payloads and plain config objects, _.values() is usually the safer default.

📝 Syntax

The signature takes one argument—the object whose values you want (including inherited):

javascript
_.valuesIn(object)

Syntax Rules

  • object — any object (instances, plain objects, etc.).
  • Return value — array of property values from own and inherited enumerable string keys.
  • Included values — own and inherited enumerable string-keyed properties.
  • Excluded — non-enumerable props, symbol keys, and nested object internals (not flattened).
  • Null-safe — returns [] for null or undefined.
javascript
import valuesIn from "lodash/valuesIn";

function Person(name, age) {
  this.name = name;
  this.age = age;
}
Person.prototype.sayHello = function () {
  console.log("Hello, " + this.name);
};

const john = new Person("John", 30);
const allValues = valuesIn(john);

// allValues includes own name/age and inherited sayHello function

⚡ Quick Reference

TaskCode patternResult
Instance + prototype_.valuesIn(instance)Own + inherited enumerable
Own values only_.values(obj)Use _.values()
Object.create chain_.valuesIn(child)Parent values included
Iterate all values_.valuesIn(o).forEach(...)Array iteration
Plain data object_.values(obj)Usually enough
Key names only_.keysIn(obj)See _.keysIn()
Scope
Inherited

+ own enumerable

Mutates?
No

Returns new array

Returns
value[]

Values only

Default
values

Plain data

🧰 Parameters

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

object Required

Any object whose own and inherited enumerable string-keyed property values are collected.

_.valuesIn(instance)
return value Output

Array of property values from the prototype chain walk, in enumeration order.

["John", 30, function sayHello() { ... }]
inherited values Scope

Enumerable values on prototypes are included—the main difference from _.values.

Object.create(parent, { ... })
non-enumerable Excluded

Non-enumerable prototype methods (common in ES classes) do not appear in the result.

class methods often skipped

On a plain object literal with no prototype extras, _.valuesIn and _.values return the same values.

Examples Gallery

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

📚 Getting Started

See inherited enumerable property values appear in the result array.

Example 1 — Constructor instance with prototype method

Include own name, age, and inherited enumerable sayHello from the prototype.

javascript
function Person(name, age) {
  this.name = name;
  this.age = age;
}

Person.prototype.sayHello = function () {
  console.log("Hello, my name is " + this.name);
};

const john = new Person("John", 30);
const allValues = _.valuesIn(john);

console.log(allValues.length);
// -> 3  (name, age, sayHello)

console.log(typeof allValues[2]);
// -> "function"
Try It Yourself

How It Works

_.values() would return only ["John", 30]; _.valuesIn walks the prototype too.

Example 2 — Object.create parent chain

Child own value plus inherited parentValue from the parent object.

javascript
const parentObject = { parentProp: "parentValue" };
const childObject = Object.create(parentObject, {
  childProp: { value: "childValue", enumerable: true }
});

const childValues = _.valuesIn(childObject);

console.log(childValues);
// -> ["childValue", "parentValue"]
Try It Yourself

📈 Practical Patterns

Compare with values, iterate inherited entries, and inspect plain objects.

Example 3 — _.valuesIn() vs _.values()

Same count on plain literals; different on prototype-augmented instances.

javascript
function Greeter(msg) { this.msg = msg; }
Greeter.prototype.greet = function () { return this.msg; };

const g = new Greeter("Hi");

console.log(_.values(g).length);    // -> 1 (own only)
console.log(_.valuesIn(g).length);  // -> 2 (own + greet)
Try It Yourself

Example 4 — Iterate all enumerable values

Log the type of every own and inherited enumerable value on an instance.

javascript
function Vehicle(type) { this.type = type; }
Vehicle.prototype.honk = function () { return "beep"; };

const car = new Vehicle("car");

_.valuesIn(car).forEach(function (value) {
  console.log(typeof value);
});
// string
// function

Example 5 — Plain object (same as values)

On a simple literal with no extra prototype keys, both methods match.

javascript
const plain = { a: 1, b: 2, c: 3 };

console.log(
  JSON.stringify(_.values(plain)) === JSON.stringify(_.valuesIn(plain))
);
// -> true

🚀 Beyond the Basics

Related key and value enumeration helpers in Lodash.

Example 6 — Pair with _.keysIn()

_.keysIn() returns key names; _.valuesIn returns the corresponding values.

javascript
function Tool(name) { this.name = name; }
Tool.prototype.use = function () { return "used"; };

const hammer = new Tool("hammer");

console.log(_.keysIn(hammer));
// -> ["name", "use"]

console.log(typeof _.valuesIn(hammer)[1]);
// -> "function"

🧠 How _.valuesIn() Works

1

Walk prototype chain

Lodash enumerates own and inherited enumerable string-keyed properties, like for...in.

Input
2

Read values

Each enumerable key contributes its current value to the result array.

Collect
3

Return array

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

Output
=

Ready to inspect

Filter by type, compare with _.values(), or pair with _.keysIn() for debugging.

📝 Notes

  • _.valuesIn() does not mutate the source object—it returns a new array.
  • Own and inherited enumerable string-keyed property values are included.
  • Nested object values are not flattened—each nested object is one array element.
  • ES class methods on the prototype are usually non-enumerable and will not appear; constructor prototype.method = fn assignments are enumerable and will.
  • On plain object literals, _.valuesIn() matches _.values().
  • For own values only, prefer _.values() or native Object.values().

Conclusion

_.valuesIn() collects own and inherited enumerable property values into one array, making prototype inspection and debugging straightforward. Pair it with _.keysIn() when you need names, or _.toPairsIn() when you need both keys and values.

For everyday data objects, _.values() is the safer default—it skips inherited prototype noise. You have now completed the Lodash object methods tutorial series; explore more from the Lodash Seq hub for method chaining.

💡 Best Practices

✅ Do

  • Use _.valuesIn for debugging prototype-augmented instances
  • Compare with _.values to see what is own vs inherited
  • Pair with _.keysIn when you need parallel key/value arrays
  • Prefer _.values for API payloads and plain config objects
  • Filter the result by typeof when separating data from functions

❌ Don’t

  • Expect _.valuesIn to flatten nested objects recursively
  • Assume ES class methods appear (they are usually non-enumerable)
  • Use _.valuesIn for summing sales data when _.values suffices
  • Serialize the result with JSON.stringify when functions are included
  • Confuse _.valuesIn with deep value extraction from nested objects

Key Takeaways

Knowledge Unlocked

Five things to remember about _.valuesIn()

Use these when inspecting own and inherited property values.

5
Core concepts
📦 02

Non-mutating

New array.

Important
🗃️ 03

vs values

Own-only default.

Compare
🔍 04

Inspection

Debug instances.

Pattern
🛠️ 05

keysIn

Names twin.

Pair

❓ Frequently Asked Questions

_.valuesIn() collects the values of an object's own and inherited enumerable string-keyed properties into a new array. Keys are not included—only property values from the prototype chain walk.
_.values() includes only own enumerable property values. _.valuesIn() also includes inherited enumerable values from prototypes—like a for...in loop turned into a values array.
No. _.valuesIn() reads the object and returns a new array. The source object is unchanged.
There is no single Object.values variant for inherited keys. You typically use a for...in loop or manual prototype walking. _.valuesIn() packages that pattern.
No. Like _.values(), it only reads top-level enumerable values on the object and its prototype chain. Nested object values stay as single elements in the array.
Use _.values() for plain data objects, API payloads, and config where inherited prototype methods should not appear. Use _.valuesIn() for debugging or inspecting prototype-augmented instances.
Did you know?

_.valuesIn() is the value-side twin of _.keysIn()—both walk the prototype chain for enumerable string keys. The old tutorial incorrectly suggested using _.flattenDeep(_.valuesIn(...)) to extract nested values; _.valuesIn only reads top-level enumerable properties and does not recurse into nested objects.

Practice _.valuesIn() in the Live Editor

Inspect prototype-augmented instances and compare with _.values() 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