array.flatten
This function creates an array with all the subarray elements concatenated into it recursively up to the specified depth.
Syntax
array.flatten(items, -1)
Arguments
Argument |
Type |
Description |
---|---|---|
items |
array of type any |
The array that you want to flatten. |
depth |
int |
The default depth is -1, which indicates no depth limit. |
Returns
Type |
Description |
---|---|
array of type any |
The flattened array |
Examples
The function array.flatten(array.create(1, 2, array.create(3,4, array.create(5,6))), -1)
returns [1,2,3,4,5,6]
.