Array:
var attr =array (array length (can not be written))
var attr =array (); It's equivalent to declaring that I'm creating an array.
Attr[key] =value; Key is unique, also known as index value
Attr[0] = "a";
ATTR[1] = "B";
Array
There are three ways to define an array:
①.attr[0] = "a"; Where the index value key is 0 corresponds to a value of a, the index value key is 1 corresponding to the value of B
ATTR[1] = "B";
②.var attr2 =array ("A", "B"); Defines an array attr2 two values of A and B, respectively.
③.var ATTR3 =["A", "B"]; Defines an array ATTR3 two values of A and B, respectively.
var x=attr.length; Defines an x, which is the length of the array.
ABCD.XYZ (); ABCD is the object,. XYZ is the method inside the calling object.
Cases:
var Attr3=array ("A", "B", "C", "D");
var x =attr3.length; The output is 4 output of 4 is X, also defines the length of this array attr3, it is a value
alert (x);
To iterate over an array:
var attr3= Array ("A", "B", "C", "C"); An array attr3 is defined, and its value is A,b,c,c
for (Var i=0;i<attr3.length;i++) {//For loop, the parentheses define an I, which is equivalent to the key within the array attr3, which is the index value, and the range is less than the length of the array.
Alert (Attr3[i]); Use the For loop to output the value of this called Attr3 array when I equals how much.
}
Learning about Arrays & arrays