First, let's look at the array classification:
From the subscript of an array into an indexed array, an associative array
Copy Code code as follows:
/* Index array, that is, an array that is usually called/
var ary1 = [1,3,5,8];
Array elements are indexed by index, starting with 0 (of course some language implementations start with 1), the index is actually ordinal, an integer number
ARY1[0];
ARY1[1];
ARY1[2];
ARY1[3];
/* Associative array, an array that is accessed as subscript with a non-ordinal type called a dictionary in Python
var ary2 = {}; Access to non ordinal (number), here is the string
ary2["one"] = 1;
Ary2["two"] = 2;
ary2["THR"] = 3;
ary2["fou"] = 4;
Question: You can test the following:
alert (arry1.length); The return value is: 4
alert (arry2.length); The return value is: 0
Because JS is a non-type language, so any type of JS is Object,
For example, var arr = [];
Arr[0] = 1;
ARR[1] = 2;
ARR[2] = 3;
Arr["s"] = 4;
At this point you call Arr.s is equivalent to calling arr This object's S property, but this is Arr.length is still 3.
Summary: Associative arrays can be subscript with strings, but this subscript is not a parameter-passing value, in other words, you need to take what you want, sounds very intelligent, in fact, you still need to take the value of the manual to write the subscript.