Home > Article > Web Front-end > js associative array indexed by object_javascript skills
Regarding JSON objects, you can refer to wikipedia (http://zh.wikipedia.org/zh-cn/JSON) and the official website (http://www.json.org/ json-zh.html).
We often say that JavaScript natively supports json, because we can think of json as a flexible application of JavaScript’s Object object.
Usually we use json, which is mainly used as the format for front-end and back-end data exchange:
In code logic, associative arrays are more commonly used. But even then we rarely use object types as the keys of key-value pairs.
var a= {}, b= [];
a[b] = new Date(); //The time value can be obtained through a[b].
The type of key name can be object, what a wonderful thing!
But there is a problem. If you want to use it this way, there is a condition: the data must be added dynamically. (Currently, I am with my classmates and have no conditions to test other browsers. Currently, I have tested IE8 and the IE kernel and weikit kernel of Sogou browser)
The test code is as follows: