Object.values()
Returns an array of an object's own enumerable property values.
Syntax
Object.values(obj) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
obj | object | Yes | The object whose enumerable own property values are returned. |
Returns
Array — An array of the own enumerable property values.
Examples
console.log(Object.values({ a: 1, b: 2 }));
Output
[ 1, 2 ]
console.log(Object.values({ x: 'a', y: 'b' }));
Output
[ 'a', 'b' ]
Notes
Order matches `Object.keys`. Only own enumerable string-keyed values are
included. Combine with `reduce` for quick aggregation.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 54 |
| firefox | 47 |
| safari | 10.1 |
| edge | 14 |
| node | 7.0 |