Performance measuring, scroll to top, array flattening

This commit is contained in:
Angelos Chalaris
2017-12-07 12:00:34 +02:00
parent accae7f71a
commit 8f4cb628a1
4 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,9 @@
### Flatten array
Use recursion.
Use `reduce()` to get all elements that are not arrays, flatten each element that is an array.
```js
var flatten = arr =>
arr.reduce( (a, v) => a.concat( Array.isArray(v) ? flatten(v) : v ), []);
```