Skip to content

Instantly share code, notes, and snippets.

@ealipio
Created January 12, 2018 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ealipio/7fb5bb025b8dd9c12923d6b2d8e36db1 to your computer and use it in GitHub Desktop.
Save ealipio/7fb5bb025b8dd9c12923d6b2d8e36db1 to your computer and use it in GitHub Desktop.
flatten an array
flattens = (arr) => arr.reduce( (flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten) , []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment