ArrayFlatten
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
Examples
Flatten a nested array completely
nested = [ 1, [ 2, [ 3, [ 4 ] ] ] ];
result = nested.flatten();
writeOutput( result.toString() );
Flatten to a specific depth
Flatten two levels deep
Using the global function form
Related
Last updated
Was this helpful?
