Created
October 10, 2017 22:40
-
-
Save amok/8bd24c0c2a493bf966d0a9319990634f to your computer and use it in GitHub Desktop.
js array flatten
This file contains hidden or 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 = 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