Concatenate the arrays in JS by using concat function or spread operator

Example 1- ES5

let array1 = [4,5,6];
let array2 = [7,8];
var array = array1.concat(array2);

console.log(array); //Output : [4, 5, 6, 7, 8]

Example 2- ES6

Arrays Concatenate in JavaScript using spread operator

let array1 = [4,5,6];
let array2 = [7,8,9];
var array = [...array1,...array2];
console.log(array); //Output : [4, 5, 6, 7, 8]


Related

String Concatenation in JavaScript
Tag Template literals (Strings) in JavaScript
Destructuring assignment in JavaScript
Difference between null and undefined in JavaScript
localStorage, sessionStorage and cookies in JavaScript?