-
-
Save nitinreddy3/d2e850f4fdb5f59c2b8db2a903ce8e64 to your computer and use it in GitHub Desktop.
Nested Array reduction to Array
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
/** | |
Array: [1, [2, 3], 4] | |
Flattens nested arrays | |
**/ | |
var nestedArray = [1, [2, 3], 4, [5, 6, 7]]; | |
nestedArray.reduce(function(a, b) { | |
return a.concat(b) | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment