githubEdit

ArrayFlatten

Flattens nested arrays to the specified depth.

When depth is omitted, the array is flattened completely.

 nested = [ 1, [ 2, [ 3 ] ] ];
 nested.flatten(); // [ 1, 2, 3 ]
 nested.flatten( 1 ); // [ 1, 2, [ 3 ] ]
 

Method Signature

ArrayFlatten(array=[array], depth=[integer])

Arguments

Argument
Type
Required
Description
Default

array

array

true

The array to flatten.

depth

integer

false

The depth to flatten. If omitted, flatten all nested arrays.

Examples

Last updated

Was this helpful?