1. braces {} indicate defining an object. In most cases, there must be a pair of attributes and values or functions. For example, VAR langshen = {"name": "langshen", "Age": "28 "}; The above declares an object named "langshen". multiple attributes or functions are separated by commas (,) because they are attributes of objects, Therefore, you should use. (point) layer-by-layer access: langshen. name, langshen. age, of course, we can also use Arrays for access, such as langshen ["name"] And langshen ["Age"]. The results are the same. This method is often used in JSON data structures. In addition, we often use it when writing function groups, such: VaR langshen = { Name = function (){ Return "langshen "; }, Age = function (){ Return "28 "; } } The call method is similar. Because it is a function group, add (), for example, alert (langshen. Name ()); 2. [] brackets indicate an array, which can also be understood as an array object. For example, VAR langshen = ["name", "langshen", "Age", "28"]; Obviously, each value or function is independent. Multiple values are separated by commas (,). Because they are array objects, they are equal: VaR langshen = array ("name", "langshen", "Age", "28 "); Alert (langshen [0]); 3. {} and [] are used together. As mentioned above, {} is an object and [] is an array. We can form an array of objects, for example: VaR langshen = {"name": "langshen ", "Mywife": ["Lulu", "26"], "Myson": [{"name": "son1" },{ "name": "son2" },{ "name": "son3"}] } From the above structure, the first attribute in an object is an attribute, the second is an array, and the third is an array containing multiple objects. Calling is also a layer-by-layer access. Object Attributes are superimposed with. (points), and arrays are accessed with [subscript. For example, alert (langshen. myson [1]. Name ); |