Concat Method (Array)

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

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

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

Parameters

Array1

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 .

Description

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.

Example

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); }


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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.