1. Method of declaring array
(1): Arrayobj = new Array (); Creates an array.
Copy Code code as follows:
(2): Arrayobj = new Array ([size]) creates an array and specifies the length, not the upper limit, but the length.
Copy Code code as follows:
(3): Arrayobj = new Array ([element0[, element1[, ...) [, ELEMENTN]]] Creates an array and assigns a value.
Copy Code code as follows:
var a = new Array (["B", 2, "a", 4,]);
(4): Arrayobj = [Element0, Element1, ..., ELEMENTN] Create an array and assign a value shorthand, note that the brackets here do not indicate that it can be omitted.
Copy Code code as follows:
var a = ["B", 2, "a", 4,];
(note): Note the difference between "[]" and "[]"
Copy Code code as follows:
var a = new Array (5); To create an array of length 5
var a = new Array ([5]); It means to create an array with a length of 1, and the first digit is 5.
2. Common methods of arrays
3. The operation of the array (send address)
Copy Code code as follows:
var t2=new Array ();
T2[0]=1;
t2[1]=2;
Test2 (T2); Send address (array)
function Test2 (var2) {
for (Var i=0;i<var2.length;i++) {
var2[i]=var2[i]+1;
}
}
for (Var i=0;i<t2.length;i++) {
Alert (T2[i]);
}