push method
Adds a new element to an array and returns the new length value of the array.
arrayObj.push([item1 [item2 [. . . [itemN ]]]])
parameter
arrayObj
Required option. An Array object.
item, item2,. . itemN
Optional. The new element of the Array.
illustrate
The push method will add the new elements in the order in which they appear. If one of the parameters is an array, the array is added to the array as a single element. If you want to merge elements from two or more arrays, you need to use the concat method.
Version requirements are in: 5.5 and applied to: array object
pop method
Removes the last element in the array and returns that element.
arrayObj.pop( )
The required arrayObj reference is an Array object.
illustrate
If the array is empty, undefined will be returned.
concat method (Array)
Returns a new array, which is composed of two or more arrays.
array1.concat([item1[, item2[, . . . [, itemN]]]])
parameter
array1
Required option. All other arrays are connected to Array objects.
item1,. . ., itemN
Optional. To connect to other items at the end of array1.
illustrate
The concat method returns an Array object containing the connection between array1 and any other items provided.
The items to be added (item1 … itemN) are added to the array in order from left to right. If an item is an array, add its contents to the end of array1. If the item is not an array, add it as a single array element to the end of the array.
The following is the copying element from the source array to the result array:
•For object parameters copied from the array being connected to the new array, copy still points to the same object. Regardless of which of the new array or the source array changes, it will cause the other to change.
•For values or strings connected to the new array, copy only its values. Changes in values in one array do not affect the values in another array.
Example
The following example illustrates the usage 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); d = a.concat(b, c); // Return array[1, 2, 3, "JScript", 42, "VBScript"] return(d);}The above article briefly discusses JavaScript's push(), pop(), and concat() methods is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.