How to merge two arrays Javascript, ES6 array spread etc

Learn how to merge two arrays in many different ways. Most of the following work on plain JS or using ES6.

Using Array.concat.

var arr1 = [1, 2, 3];
var arr2 = [4, 5, 6];
var array3 = arr1.concat(arr2);
// > [1, 2, 3, 4, 5, 6]

Using Array spread syntax

var arr1 = [1, 2, 3];
var arr2 = [4, 5, 6];
var array3 = [...arr1, ...arr2];
// > [1, 2, 3, 4, 5, 6]

Using Array.push with Array spread syntax

var arr1 = [1, 2, 3];
var arr2 = [4, 5, 6];
var array3 = arr1.push(...arr2);
// > [1, 2, 3, 4, 5, 6]

Using Array.concat with Array spread syntax

var arr1 = [1, 2, 3];
var arr2 = [4, 5, 6];
var array3 = arr1.concat(...arr2);
// > [1, 2, 3, 4, 5, 6]