Concat Method (Array)

Source: Internet
Author: User
Tags add array arrays object end return

Returns a new array, which is a combination of two or more arrays.

array1.concat([item1[, item2[, . . . [, itemN]]]])



Required option. The array object to which all other arrays are to be connected.

Item1,.. ., itemn

Options available. Other items to connect to the end of array1 .


The concat method returns an Array object that contains a connection to the array1 and any other items provided.

Items to add (item1 ... itemn) are added to the array in Left-to-right order. If an item is an array, add its contents to the end of the array1 . If the item is not an array, it is added to the end of the array as a single array element.

The following is a copy of an element from the source array to the result array:

    • For object parameters copied from the array being connected to the new array, the same object is still pointed to after replication. Whatever changes in the new array and source array will cause another change.
    • For a numeric or string connection to a new array, only its value is copied. A change in the value of an array does not affect the value in the other array.


The following example illustrates the use of the concat method when using an array:

function ConcatArrayDemo(){var a, b, c, d;   a = new Array(1,2,3);   b = "JScript";   c = new Array(42, "VBScript);a.concat(b, c);    Return array  [1, 2, 3, "JScript", 42, "VBScript"]    return(d); }

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.