Skip to content

Instantly share code, notes, and snippets.

@akinolu52
Created January 6, 2019 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akinolu52/f423f3af15ed7f7e5cc2e74c671e05d7 to your computer and use it in GitHub Desktop.
Save akinolu52/f423f3af15ed7f7e5cc2e74c671e05d7 to your computer and use it in GitHub Desktop.
to flatten an array in Javascript
function flattenArray(arr) {
return arr.reduce((acc, e) => Array.isArray(e) ? acc.concat(flattenDeep(e)) : acc.concat(e), []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment