SHARE
TWEET

Untitled

a guest May 19th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flatten(arr) {
  2.   if (Array.isArray(arr)) {
  3.   return arr.reduce(function(done,curr){
  4.     return done.concat(flatten(curr));
  5.     }, []);
  6.   } else {
  7.     return arr;
  8.   }
  9. }
  10.  
  11. // [ 1, 2, 3, 4 ]
RAW Paste Data
Top