Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 503 Bytes

flat.md

File metadata and controls

33 lines (21 loc) · 503 Bytes

arrays.flat

flat(array, [depth=1])

Flat flattens an array of nested arrays

Arguments

  1. array (Array): input array
  2. [depth=1] (number): depth of array elements to flat

Returns

(Array): the flattened array

Example

const result = arrays.flat([1, [2, [3, [4]]]]);
console.log(result);
> [1, 2, [3, [4]]]