Array is inherited from Object. It has all the functions and characteristics of Object. The following is the case of Object:
New: var object = new Object();
Add: object[strIndex] = value; (strIndex is string)
Delete: delete object[strIndex];
Traversal: for (var strObjIndex in object) object[strObjIndex];
is as follows:
Because Array inherits Object, Array can also use strings as array subscripts:
As follows
For traversing array numbers, we use a for loop statement. But this for loop is not in this form:
We can use for/in loop to traverse the array. The for/in loop temporarily assigns the subscript of an array to a variable:
In the first loop, the variable variable will be assigned the subscript value of the first element of the array; in the second loop, the variable variable will be assigned the subscript value of the second element of the array array. scalar value; and so on....
For the above array, use for/in loop to traverse: