Skip to content

Instantly share code, notes, and snippets.

@peterforgacs
Created November 9, 2019 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterforgacs/1b31d0209ac22e5ac097a06a5da7005c to your computer and use it in GitHub Desktop.
Save peterforgacs/1b31d0209ac22e5ac097a06a5da7005c to your computer and use it in GitHub Desktop.
let arr = [ [1, 2], [3, 4]];
// version 1
arr.reduce((acc, curr) => acc.concat(curr), []);
// version 2
arr.reduce((acc, curr) => [...acc, ...curr], []);
// version 3
[].concat(...arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment