Description

Flattens an array.

Type Signature

.flat(depth = 1): any[]

Syntax

console.log([1, 2, [3, 4], [[5, 6]]].flat(0)); // [ 1, 2, [ 3, 4 ], [ [ 5, 6 ] ] ]
console.log([1, 2, [3, 4], [[5, 6]]].flat(1)); // [ 1, 2, 3, 4, [ 5, 6 ] ]
console.log([1, 2, [3, 4], [[5, 6]]].flat(2)); // [ 1, 2, 3, 4, 5, 6 ]