ES6 - Array Method concat()


Advertisements

concat() method returns a new array comprised of this array joined with two or more arrays.

Syntax

array.concat(value1, value2, ..., valueN);

Parameters

  • valueN − Arrays and/or values to concatenate to the resulting array.

Return Value

Returns a new array.

Example

var alpha = ["a", "b", "c"]; 
var numeric = [1, 2, 3];
var alphaNumeric = alpha.concat(numeric); 
console.log("alphaNumeric : " + alphaNumeric ); 

Output

alphaNumeric : a,b,c,1,2,3
es6_arrays.htm
Advertisements