JavaScript (ES2026) reference · Object Methods
JavaScript Object.values() Method
Return an array of an object's own enumerable property values, in the same order as Object.keys().
JavaScript (ES2026) Since ES2017
Syntax
Object.values(obj)
Parameters
| Parameter | Description |
|---|---|
obj |
The object to inspect or change. |
Return value
An array of values.
Examples
const scores = { ada: 92, linus: 85, grace: 97 };
console.log(Object.values(scores));
Output
[ 92, 85, 97 ]
const cart = { tea: 3, cake: 4.5, milk: 1.2 };
console.log(Object.values(cart).reduce((sum, p) => sum + p, 0));
Output
8.7
Version history
| Version | Change |
|---|---|
| JavaScript ES2017 | Added |
In other languages
dict.values()· Pythonarray_values()· PHP
Related
Object.keys()· Return an array of an object's own enumerable property names, in insertion order (integer keys first).Object.entries()· Return an array of an object's own enumerable [key, value] pairs, ready for for…of loops or array methods.array.reduce()· Reduce the array to a single value by running a reducer function on each element, carrying an accumulator along.- JavaScript Objects · tutorial