Skip to content

Instantly share code, notes, and snippets.

@yxy
Last active May 13, 2016 09:01
Show Gist options
  • Save yxy/f989e56ea808d24a87a5451d8199cda5 to your computer and use it in GitHub Desktop.
Save yxy/f989e56ea808d24a87a5451d8199cda5 to your computer and use it in GitHub Desktop.
flatten array snippet
flatten = function (a, b) {
if (!Array.isArray(a)) {
a = [a];
}
return a.concat(b);
}
// usage
var aa = [[1], [2, 3], [4, 5]];
aa.reduce(flatten);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment