- Instant help with your JavaScript coding problems

Append an array to another in JavaScript

Question:
How to append an array to another in JavaScript?
Answer:
let myArray1 = [1,2,3];
let myArray2 = [5,6,7];

myArray1 = [...myArray1, ...myArray2];

// myArray1 is [1,2,3,5,6,7]
Description:

JavaScript has multiple ways to concatenate 2 or more arrays into one. You can use concat or push methods, but the simplest solution is the spread operator.

Share "How to append an array to another in JavaScript?"