English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Array concat() Method

 JavaScript Array Object

concat()The method is used to merge two or more arrays.

This method does not change the existing array but returns a new array.

Syntax:

array.concat(array1, array2, ..., arrayZ)
var fruits = ["Apple", "Mango", "Banana"];
var numbers = [5, 10, 12, 98, 3];
var arr = fruits.concat(numbers);
Test and See‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the concat() method:

Method
concat()11IsIs5.5

Parameter Value

ParameterDescription
array1, array2, ..., arrayZThe arrays to be merged

Technical Details

Return Value:A new Array example
JavaScript Version:ECMAScript 1

More Examples

The following code concatenates three arrays:

var num1 = [1, 2, 3];
var num2 = [4, 5, 6];
var num3 = [7, 8, 9];
var nums = num1.concat(num2, num3);
Test and See‹/›

The following code adds three values to an array:

var alpha = ['a', 'b', 'c'
var alphaNumeric = alpha.concat(1, 2, [3, 4, 5]);
Test and See‹/›

 JavaScript Array Object