Files
30-seconds-of-code/snippets/flatten.md
Angelos Chalaris 0108f8859d Update flatten.md
2017-12-23 12:00:38 +02:00

11 lines
242 B
Markdown

### flatten
Flattens an array.
Use a new array and concatenate it with the spread input array causing a shallow denesting of any contained arrays.
```js
const flatten = arr => [ ].concat( ...arr );
// flatten([1,[2],3,4]) -> [1,2,3,4]
```