Object.values()
The half of the keys/values/entries trio you want when the keys are irrelevant — totalling a record of amounts, or checking whether any field is set.
Demo
Values come back in key order, which is why the second case matters: the property written first is returned SECOND, because its sibling has an integer-like key and those are always listed first. If you are pairing values against a separately-computed list of keys, that reordering will silently misalign them — use Object.entries, which keeps each key attached to its value. Nested objects are returned as references, not copied or flattened.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| object | object | yes | Any object. Primitives are coerced; null and undefined throw TypeError. |
Return value
any[] — The object own enumerable property values, in exactly the order Object.keys would list their keys.
Common patterns
const total = Object.values(amounts).reduce((a, b) => a + b, 0);
const anyFilled = Object.values(form).some(Boolean);
const list = Object.values(byId);
Examples
Pitfalls
Object.values({b: 'first', 1: 'second'})
Object.entries({b: 'first', 1: 'second'})
const src = {a: {x: 1}}; Object.values(src)[0].x = 9; src.a.x
structuredClone(src)
Object.values(maybeNull)
Object.values(maybeNull ?? {})
const o = {}; Object.defineProperty(o, 'h', {value: 1}); Object.values(o)
Object.getOwnPropertyDescriptors(o)
When to use
- Aggregating — sums, averages, maxima over a keyed record
- Testing whether any or every value satisfies a condition
- Converting a keyed store into a list for rendering
- You need the keys too → Object.entries
- You need only the keys → Object.keys
- The order must be insertion order → a Map
- You want a deep copy → structuredClone
Notes
FAQ
Yes. All three of keys, values and entries use the same ordering algorithm, so the nth value corresponds to the nth key. What is not guaranteed is that the order matches how you wrote the object — integer-like keys jump to the front.