Skip to content

Instantly share code, notes, and snippets.

@wwwmarcos
Created December 19, 2019 12:23
Show Gist options
  • Save wwwmarcos/a0e75a81308866efe431e67403aa3aaa to your computer and use it in GitHub Desktop.
Save wwwmarcos/a0e75a81308866efe431e67403aa3aaa to your computer and use it in GitHub Desktop.
const myArray = [1, 2, 3]
myArray.push(...[5, 6, 7])
console.log(myArray) // Array(6) [ 1, 2, 3, 5, 6, 7 ]
const newArray = [...myArray, 8, 9, 10]
console.log(newArray) // Array(9) [ 1, 2, 3, 5, 6, 7, 8, 9, 10 ]
const anotherArray = newArray.concat([11, 12])
console.log(anotherArray) // Array(11) [ 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment