Skip to content

Instantly share code, notes, and snippets.

@davidicus
Created December 25, 2017 20:52
Show Gist options
  • Save davidicus/4a7530a55a7c2f419cfc6348327b7520 to your computer and use it in GitHub Desktop.
Save davidicus/4a7530a55a7c2f419cfc6348327b7520 to your computer and use it in GitHub Desktop.
Flatten an array of arrays
var flattened = [[0, 1], [2, 3], [4, 5]].reduce(
( acc, cur ) => acc.concat(cur),
[]
);
// flattened is [0, 1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment