Recursively flattens an array up to the specified depth.
Fully flattens if depth is Infinity (default).
Infinity
The array to flatten.
Maximum depth to flatten. Default: Infinity.
Flattened array up to the specified depth.
flattenDeep([1, [2, [3, [4]]]], 2);// → [1, 2, 3, [4]]flattenDeep([1, [2, [3, [4]]]]);// → [1, 2, 3, 4] Copy
flattenDeep([1, [2, [3, [4]]]], 2);// → [1, 2, 3, [4]]flattenDeep([1, [2, [3, [4]]]]);// → [1, 2, 3, 4]
1.2.0
Recursively flattens an array up to the specified depth.
Fully flattens if depth is
Infinity
(default).