Recursively flatten array up to depth times.
array
depth
The array to flatten.
The maximum recursion depth.
Returns the new flattened array.
5.4.0
[[flatMap]],[[flatMapDeep]],[[flatMapDepth]],[[flattenDeep]]
const array = [1, [2, [3, [4]], 5]]flattenDepth(array, 1)// => [1, 2, [3, [4]], 5]flattenDepth(array, 2)// => [1, 2, 3, [4], 5] Copy
const array = [1, [2, [3, [4]], 5]]flattenDepth(array, 1)// => [1, 2, [3, [4]], 5]flattenDepth(array, 2)// => [1, 2, 3, [4], 5]
Recursively flatten
array
up todepth
times.