Last active
March 16, 2019 05:29
-
-
Save carlbarrdahl/e5ba2ce8032af89e3571f4b5c83919b7 to your computer and use it in GitHub Desktop.
ES6 flatten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flatten = arr => | |
arr.reduce( | |
(acc, curr) => acc.concat(Array.isArray(curr) ? flatten(curr) : curr), | |
[] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment