Skip to content

Instantly share code, notes, and snippets.

@amok
Created October 10, 2017 22:40
Show Gist options
  • Select an option

  • Save amok/8bd24c0c2a493bf966d0a9319990634f to your computer and use it in GitHub Desktop.

Select an option

Save amok/8bd24c0c2a493bf966d0a9319990634f to your computer and use it in GitHub Desktop.
js array flatten
const flatten = a => a.reduce((memo, value) => {
return Array.isArray(value) ?
[...memo, ...flatten(value)] :
[...memo, value]
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment