Guest User

Untitled

a guest
Nov 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.17 KB | None | 0 0
  1. function flatten (a) {
  2. return [].concat( ...a.map(x => Array.isArray(x) ? flatten(x) : x) )
  3. }
  4.  
  5. flatten([1, 2, [3, 4, [5], 6, [7, [8]]]])
  6. // [ 1, 2, 3, 4, 5, 6, 7, 8 ]
Add Comment
Please, Sign In to add comment