/array/flatten
stdFlattens the nested arrays by a single level.
Type signature
<T>(xs: T[]) => T[]
Examples
flatten([1, [2, 3], 4, [5, 6]]);
// ⇒ [1, 2, 3, 4, 5, 6]
Try in REPL
flatten([
1,
[2, [3, 6]],
4,
[5, 6],
]);
// ⇒ [1, 2, [3, 6], 4, 5, 6]
Try in REPL
Questions
- How to flatten an array?