Use of the Concat method of JS

Source: Internet
Author: User

Concat method (array)
Returns a new array consisting of two or more arrays.

Array1.concat ([Item1 [, item2 [,... [, itemn])

Parameters
Array1

Required. The array object to be connected to all other arrays.

Item1,..., itemn

Optional. To connect to another project at the end of array1.

Description
The Concat method returns an array object that contains the connection between array1 and any other projects provided.

Project to be added (Item1... Itemn) is added to the array from left to right. If an item is an array, add its content to the end of array1. If the project is not an array, add it as a single array element to the end of the array.

Copy elements from the source array to the result array as follows:

For the object parameters copied from the array being connected to the new array, the Copied object still points to the same object. Any change in the new array and source array will lead to another change.
Only the values of the values or strings connected to the new array are copied. Changing the value of a group does not affect the value of another array.
Example
The following example illustrates the usage of the Concat method when arrays are used:

Function concatarraydemo (){
VaR a, B, c, d;
A = new array (1, 2, 3 );
B = "jscript ";
C = new array (42, "VBScript );
D = A. Concat (B, c );
// Returns the 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.