Last active
January 16, 2019 12:32
-
-
Save jonasantonelli/0c0ce127b7e0fc819ddb4f4eaf9c7a68 to your computer and use it in GitHub Desktop.
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
function flattenDeep(arr) { | |
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []); | |
} | |
flattenDeep([[1,2,[3]],4]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flatten Deep JS function