Skip to content

Instantly share code, notes, and snippets.

@helloncanella
Last active February 4, 2017 22:02
Show Gist options
  • Save helloncanella/dd24ea31bc0eb37fd2dcbecd69138644 to your computer and use it in GitHub Desktop.
Save helloncanella/dd24ea31bc0eb37fd2dcbecd69138644 to your computer and use it in GitHub Desktop.
short version of flatten.js
function flatten(A){
return A.reduce((previous, current) =>{
if(Array.isArray(current)) current = flatten(current)
return previous.concat(current)
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment