Edit this page

up.util up.util.flatten(array)
JavaScript function

This feature is experimental. Please share your experiences so we know what to keep or change.

Flattens the given array a single depth level.

Example

```js let nested = [1, [2, 3], [4]] up.util.flatten(nested) // => [1, 2, 3, 4]


Parameters

array Array

An array which might contain other arrays

Return value

Array

The flattened array