Reading todayJavascriptWhen, suddenly find the ArrayArrayThe character string can be used as its subscript. I still don't know before. In my opinion, how can I use a character string for Array traversal? Ah .. Ignorant.....
FirstArrayYesfromObjectIt inherits. It hasObjectAll functions and features. Below isObject:
Create: var object = new object (); add: object [strindex] = value; (strindex is string) Delete: delete object [strindex]; traverse: for (VAR strobjindex in object) object [strobjindex];
As follows:
1VaROBJ =NewObject ();2OBJ ["first"] = "my";3OBJ ["second"] = "name";4OBJ ["third"] = "is";5OBJ ["fourth"] = "chenssy ";
BecauseArrayInheritanceObject, ThenArrayYou can also use a string as the underlying object of the array:
As follows:
1VaRArray =NewArray ();2Array ["first"] = "my";3Array ["second"] = "name";4Array ["third"] = "is";5Array ["fourth"] = "chenssy ";
ForArrayNumber traversal, we useForLoop statement. But thisForLoop is not in this form:
1 For(IntI = 0; I <arrray. length; I ++)
We can useFor/inLoop to traverse the array.For/inIn a loop, the subscript of an array is temporarily assigned to a variable:
1 For(VariableInArray)
In the first cycle, the variable variable is assigned as an array array indicates the lower value of the first element. In the second loop, variable variable will be assigned an array array the lower value of the second element, and so on .......
ForArrayArray, usingFor/inLoop traversal:
1 For(KeyInArray)