Javascript - Array Array Concatenation

Introduction

The concat() method creates a new array by combining arrays.

This method begins by creating a copy of the array and then appending the method arguments to the end and returning the newly constructed array.

When no arguments are passed in, concat() simply clones the array and returns it.

If one or more arrays are passed in, concat() appends each item in these arrays to the end of the result.

If the values are not arrays, they are simply appended to the end of the resulting array.

Demo

var colors = ["red", "green", "blue"];
var colors2 = colors.concat("yellow", ["black", "brown"]);

console.log(colors);     //red,green,blue
console.log(colors2);    //red,green,blue,yellow,black,brown

Result