For details about the number objects in the third part of Javascript development, see var a = new Array ();
If the definition is as follows: a [3] = "a"; alert (a. length) 4 is 1,
If yes, but no value is assigned, an undefined (alert (a [0]) is returned.
Create an array:
The Code is as follows:
Arr = []; // Yes, an air Bracket
// It is almost equivalent to the following sentence
Arr = new Array (); var a = new Array (1, "n", 3, "m", 5, "m", 8 );
Var a = []; // defines an empty array
Var a = new Array (2); // defines an Array with a length of 2.
Var a = [2]; defines an array with an initial value of 2
Var a = [1, 2, 2, 3, 4, 4];
Add or delete elements to an array)
The Code is as follows:
Var arr = [4545,5456, 64646];
Arr. push (); // append two elements to the end of the array
Delete arr [2]; // delete each of the three elements directly, but the position is retained, indicating that the length has not changed, so that we can continue to access the elements in the original position.
Use of the join method in the array: Purpose:
Var arr = [1, 2, 4];
Alert (arr. join ("#") 1 #2 #3 #4
Array Performance Improvement:
The Code is 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 );