Array is inherited from object. It has all the functions and properties of object. Here is the case of object:
NEW: var object = new Object ();
Add: object[strindex] = value; (Strindex to String)
Delete: delete Object[strindex];
Traversal: for (var strobjindex in object) Object[strobjindex];
As follows:
Copy Code code as follows:
var obj = new Object ();
Obj["a" = "my";
Obj["Second"] = "name";
obj["Third"] = "is";
obj["Fourth"] = "Chenssy";
Because array inherits object, array can also use a string as the subject of the array:
As follows
Copy Code code as follows:
var array = new Array ();
Array["a" = "my";
Array["Second"] = "name";
array["Third"] = "is";
array["Fourth"] = "Chenssy";
For the traversal of array numbers, we take a For loop statement. But this for loop is not in this form:
Copy Code code as follows:
for (int i = 0;i<arrray.length;i++)
We can use the for/in loop to iterate through the array. The for/in Loop assigns the subscript of an array to a variable temporarily:
Copy Code code as follows:
At the first loop, the variable variable is assigned the subscript value of the first element of the array, and, on the second loop, the variable variable will be assigned the subscript value of the second element of the array of arrays;
For the array above, use the for/in loop to iterate through:
Copy Code code as follows: