Skip to content

Instantly share code, notes, and snippets.

@nitinreddy3
Last active October 20, 2016 01:44
Show Gist options
  • Save nitinreddy3/d2e850f4fdb5f59c2b8db2a903ce8e64 to your computer and use it in GitHub Desktop.
Save nitinreddy3/d2e850f4fdb5f59c2b8db2a903ce8e64 to your computer and use it in GitHub Desktop.
Nested Array reduction to Array
/**
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