var a=new Array ();
If this definition: a[3]= "a"; Alert (A.length) 4 instead of 1,
If defined, but not assigned, returns a undefined (alert (a[0))
To create an array :
Copy Code code as follows:
arr = [];//Yes, an aerial bracket
is almost equivalent to the following sentence
arr = new Array (); var a=new array (1, "N", 3, "M", 5, "M", 8);
var a=[]; Define an empty array
var a=new Array (2); Defines an array of length 2
var a=[2]; Defines an array with an initial value of 2
var a=[1,2,2,2,3,4,4,4];
Add to Array, delete element (Push,delete)
Copy Code code as follows:
var arr=[4545,5456,64646];
Arr.push (55,88); Append two elements to the end of an array
The delete arr[2];//directly deletes every three elements, but the position remains, indicating that the length has not changed, so that we can continue to access the elements of the original location.
Use of join methods in arrays: function:
var arr=[1,2,3,4];
Alert (Arr.join ("#")) 1#2#3#4
improvement of array performance:
Copy Code code as follows:
var starta=new Date (). GetTime ();
var s=["Start"];
for (Var i=0;i<999999;i++)
{
S.push ("ABC");
}
S.join ("");
Alert (new Date (). GetTime ()-starta);
Starta=new Date (). GetTime ();
var arr=[];
var s= "Start";
for (Var i=0;i<999999;i++)
{
s+= "ABC";
}
Alert (new Date (). GetTime ()-starta);