JavaScript has four semantics in parentheses
Semantic 1, declaring an array
Copy Code code as follows:
var ary = []; Declare an empty array
var ary = [1,3]; Declare an array, and assign an initial value
Semantic 2, taking an array member
Copy Code code as follows:
var ary = [1,2,3];
var item = ary[0];
Semantic 3, defining an object member (you may not follow an identifier rule)
Copy Code code as follows:
var obj = {};
Adding a property to obj Name,name is a valid identifier, that is, it can also be defined by the Obj.name method
obj[' name ' = ' Jack ';
Adding a property to obj 2a,2a is not a valid identifier (cannot begin with a number) and cannot be defined by obj.2a
obj[' 2a '] = ' test ';
Semantic 4, fetching object members
Copy Code code as follows:
var obj = {name: ' Jack '};
obj[' 2a '] = ' test ';
obj[' name ']; -->, Jack.
obj[' 2a ']; --> test (not available through obj.2a)