1. Method of declaring array
(1): Arrayobj = new Array (); Creates an array.
The code is as follows:
(2): Arrayobj = new Array ([size])
creates an array and specifies the length, not the upper limit, but the length.
The code is as follows:
(3): Arrayobj = new Array ([element0[, element1[, ...) [, ELEMENTN]]]
creates an array and assigns a value.
The code is 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.
The code is as follows:
var a = ["B", 2, "a", 4,];
(note): Note the difference between "[]" and "[]"
The code is as follows:
var a = new Array (5); The creation of an array of length 5,
var a = new Array ([5]), or the creation of an array with a length of 1 and a first digit of 5
2. Common methods of arrays
3. The operation of the array (send address)
The code is as follows:
var t2=new Array ();
T2[0]=1;
t2[1]=2;
Test2 (T2); Pass address (array)
function test2 (var2) {for
(var i=0;i
var2[i]=var2[i]+1;
}
}
for (Var i=0;i
alert (t2[i]);
}
The above JS to create an array of simple method is small set to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.