Skip to content

Instantly share code, notes, and snippets.

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 cjlaborde/794b5d475eeb2689b36de9009646933e to your computer and use it in GitHub Desktop.
Save cjlaborde/794b5d475eeb2689b36de9009646933e to your computer and use it in GitHub Desktop.
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
Short Version
const mergedarray = [].concat(...yourArrays);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment