Skip to content

Instantly share code, notes, and snippets.

@EnetoJara
Created January 9, 2020 12:47
Show Gist options
  • Save EnetoJara/97fac88cbfa5067c5f27c1385476b125 to your computer and use it in GitHub Desktop.
Save EnetoJara/97fac88cbfa5067c5f27c1385476b125 to your computer and use it in GitHub Desktop.
const flat = (base, val) => Array.isArray(val) ? base.concat(val.reduce(flat, [])) :base.concat(val);
const map = arr => arr.reduce(flat, []);
console.log(map([1,23,[3,[3,1,[3,4],5],6],5]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment