Skip to content

Instantly share code, notes, and snippets.

@industral
Last active January 10, 2018 08:01
Show Gist options
  • Save industral/7d68d10f8b3c241245aae51d36396685 to your computer and use it in GitHub Desktop.
Save industral/7d68d10f8b3c241245aae51d36396685 to your computer and use it in GitHub Desktop.
Array flattering
var array = [[['a','b','c'],[1,2,3]],[],[['d','e','f','g','h'],[4,5,6,7]]]
function flat(data) {
return data.reduce((r, e) => r.concat(Array.isArray(e) ? flat(e) : e), [])
}
console.log(flat(array))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment