JS Built-ins
← Object116 / 150
ObjectObject.valuesbeginner

Object.values() β€” basic usage

πŸ“– Usage Example
// Get array of own enumerable property values
const obj = { a: 1, b: 2, c: 3 }
Object.values(obj)   // β†’ [1, 2, 3]

Use Object.values() to get an array of an object's own enumerable property values for easy iteration.

Object.values()

Object.values(obj) returns an array of the object's own enumerable string-keyed property values, in the same order as for...in.

Challenge: Implement getValues(obj) that returns an array of the object's own enumerable property values.

πŸ’‘ Hints (1)
  • β€’ Object.values is the counterpart to Object.keys