(1): Add an element to the array: var array = [];
VaR
Array = [];
Array. Push (123 );
Array. Push (456 );
Array. Push (false );
Array. Push ("M ");
Array. Push ("");
Array. Push ("S ");
For (VAR item in array ){
Alert (typeof
Array [item]);
}
(2) Pop pops up the elements in the array.
VaR array = [];
Array. Push (123 );
Array. Push (456 );
Array. Push (false );
Array. Push ("M ");
Array. Push ("");
Array. Push ("S ");
VaR Len = array. length;
For (VAR
I = 0; I <Len; I ++ ){
Alert (array. Pop ());
}
Alert ("length of the last array:" + array. Length );
(3) join
VaR array = [];
Array. Push (123 );
Array. Push (456 );
Array. Push (false );
Array. Push ("M ");
Array. Push ("");
Array. Push ("S ");
VaR str1 = array. Join (",");
VaR str2 = array. Join ("| ");
Alert (str1 );
Alert (str2 );
The printed result is:
123,456, false, M, A, S
Concatenates an array into a string.
123 | 456 | false | M | A | S
Use | to cut the array into a string...
(4) Contact
Combine the arrays another and another2 into an array (all the elements of the three arrays are available)
VaR Bigarray=Array. Concat (another,Another2 );
(5)
Alert (bigarray. Slice (5, 9 ));Returns the starting position of the first parameter to the ending position of the second parameter. The array itself is not affected.
(6) splice Method
1.
Bigarray. splice (5,2 );
2:Bigarray. splice (5,0,"","B ","B ","D ");
The first line of code indicates that two elements are deleted from the bigarray array and the second line of code indicates that 0 elements are deleted from the first element, insert all subsequent parameters to the starting position from 5th.