a , how to create an array
(1) created by the object's way.
var a=new Array ();
A. Direct Assignment
var a=new Array ( element 1, Element 2, Element 3, Element 4,........)
var a=new Array ( numeric )
If there is only one element, and this element is a numeric type, then he is the length of the specified array.
And his values are undefined .
Properties of the array : Length Property
B. declaring a later assignment
var a=new Array ();
A[0]=1;
a[2]=2;
a[0]=3;
(2) the way of stealth declaration
var a=[];
A. Direct Assignment :
var a=[1,2,3,4];
B. declaring a later assignment
var a=[];
A[0]=1;
a[1]=2;
a[2]=3;
J the Avascript array can store values of any type.
Second, accessing elements of an array
Accessed through an array of ( brackets ) subscript .
Third, iterate over the elements of the array
(1) for Loop
(2) while ();
(3) for in
Iv. Classification of arrays:
1. type of subscript
A. Subscript is the type of the number ( indexed array )
B. The subscript is a string type ( associative array )
2. dimensions to classify
A. one-dimensional arrays
B. two-dimensional arrays
Declare a two-dimensional array :
var arr=[[1,2,3],[4,5,6]];
This article is from the "Mr.zhu-Technology Exchange" blog, please be sure to keep this source http://bjishu.blog.51cto.com/7481301/1671812
JavaScript several rent