Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

Object.values

Object.values() returns an array of an object's own enumerable string-keyed property values. It excludes inherited and symbol-keyed properties.

Since
ES2017

How it works

Object.values() converts its argument to an object, gathers the values of its own enumerable properties whose keys are strings, and returns those values in property-enumeration order. It does not include inherited properties or symbol-keyed properties.

Syntax

Object.values(obj)

Parameters

NameTypeDescription
objobjectThe value whose own enumerable string-keyed property values should be collected.

Returns

An array containing the given object's own enumerable string-keyed property values.

Key points

  • The result is an array containing values from the object's own enumerable string-keyed properties.
  • Returned values use the same enumeration order as a for...in loop over the object's own enumerable string properties.
  • Unlike for...in, the method does not include enumerable properties inherited through the prototype chain.
  • Use Object.keys() when the required result is the enumerable own string-key names rather than their values.
  • Use Object.entries() when each key must remain associated with its corresponding value.
  • The argument need not already be an object because the method coerces non-object arguments.

Common mistakes

  • Passing undefined or null throws a TypeError instead of returning an empty array.
  • Primitive values other than strings produce an empty array; a string produces its character-index values.

Example: Collect an object's values

const user = { name: "Ada", active: true, visits: 3 };
const values = Object.values(user);
console.log(values); // ["Ada", true, 3]

Creates an array containing the object's own enumerable string-keyed values.

When to use it

Extract values for mapping or filtering

Transforming records

Inspect whether any stored value meets a condition

Validating state

Render values without manually iterating over keys

Displaying data

Interview questions

QWhat does Object.values() return?

It returns an array of an object's own enumerable string-keyed property values. Inherited properties and symbol-keyed properties are excluded.

Follow-up: How would you obtain both keys and values? Use Object.entries(), which returns paired key-value arrays.

QWhat ordering and ownership rules apply?

The array follows the same property order used by a for...in loop for the object's own enumerable string-keyed properties. Unlike for...in, it does not continue through the prototype chain.

Follow-up: How can you include inherited enumerable properties? Iterate with for...in, while applying an ownership check if only selected inherited behavior is intended.

QHow does it behave with primitives?

Its parameter is coerced to an object. null and undefined cannot be coerced and throw TypeError; strings expose their indexed characters, while other primitives return no values.

Follow-up: What should be used when property names are needed rather than values? Use Object.keys().

  • Object.keys()
  • Object.entries()
  • for...in

Source: Object.values() - JavaScript - MDN Web Docs - Mozilla. Checked 2026-10-15.