Object.values()

Get an Object's property values as an Array.

Signature

Object.values(object: { *: A }) => Array<A>

Description

Object.values() returns an Array containing an Object’s property values. Object.values() does not change the original Object.

Parameters

Parameter Type Required Description

object

Object containing fields of Any type.

Yes

Object to get property values from.

Return value

Type Description

Array

Array of values extracted from the Object.

Examples

Basic example

Object.values({ a: 0, b: 1 })
[
  0,
  1
]

Objects with non-scalar values

Any nested Arrays in the original Object are left intact, resulting in a multi-dimensional Array. For example:

Object.values({ a: [1, 2], b: 'foo' })
[
  [
    1,
    2
  ],
  "foo"
]

Similarly, any nested Objects in the original Object are left intact:

Object.values({ a: { x: 1, y: 2 }, b: 'foo' })
[
  {
    x: 1,
    y: 2
  },
  "foo"
]

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!