Javascript data sharing-javascript tips-js tutorials
Source: Internet
Author: User
Imitate the js data of Baidu 3D map. For more information, see. Javascript data format of Baidu 3D map: mapData ["sign"] ["5,158,141"] = {"busStation": {"4,317,282": [{"id": "ff80811c462eb7011d2e23d5b91083 ", "name": "geographic site", "y": 579152, "x": 650606}, {"id": "ff8080811c462eb7011d2e2414f31085", "name": "geographic site ", "y": 579176, "x": 650750}], "4,316,283": [{"id": "ff80811c462eb7011d2cc3d5630ef3", "name": "whitelist ", "y": 580232, "x": 648834}]}
First, let's take a look at the concept of an object as an associated array:
Var o = new Object ();
O. x = "Hello! ";
We have defined an object. an attribute of an object is x, which is common. Objects in JavaScript can be used as correlated arrays because they can associate arbitrary data values with arbitrary strings. If you use an object in this way, you must use different syntaxes for the object to be accessed, that is, a string enclosed by square brackets containing the required attribute names, using this syntax, we can assign values to the x attribute of the above o object as follows:
Var o = new Object ();
O ["x"] = "Hello! "
This method is necessary in some cases. For example, if you do not know the attribute name, you cannot use it ". "To access the attributes of an object, but you can use the [] operator to name attributes, because its attribute name is a string value (this value is dynamic and can be changed at runtime ), instead of an identifier (it is static and must be hard-coded in the program ). If you use this method when using an object, we call it an associated array. (For details, see JavaScript authoritative guide (version 4) (page 155 ))
As described above, we can define an object as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service