Push (), pop (), concat () method, pushconcat
Push method
Add the new element to an array and return the new Length Value of the array.
ArrayObj. push ([item1 [item2 [... [itemN])
Parameters
ArrayObj
Required. An Array object.
Item, item2,... itemN
Optional. The new element of the Array.
Description
The push method adds new elements in the order they appear. If one of the parameters is an array, the array will be added to the array as a single element. To merge two or more elements in an array, use the concat method.
Version 5.5 must be applied to: array objects.
Pop Method
Removes the last element from the array and returns the element.
ArrayObj. pop ()
The required arrayObj reference is an Array object.
Description
If this array is empty, undefined is returned.
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.
• For values or strings connected to the new array, only the values 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 =. concat (B, c); // returns an array [1, 2, 3, "JScript", 42, "VBScript"] return (d );}
The push (), pop (), and concat () methods in JavaScript are all shared by Alibaba Cloud. I hope you can give me a reference, we also hope that you can support the customer's home.