flatten()

Flatten the array elements.

Signature

flatten(): Array<T>

Description

The flatten() method flattens the array elements, which returns a one-dimensional array.

The source array must be an array of arrays. If there are non-array elements in the array, the function aborts the query.

Parameters

None

Return value

Type Description

Array

One-dimensional representation of the array instance.

Examples

[[1, 2], [3, 4]].flatten()
[
  1,
  2,
  3,
  4
]

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!