This article mainly introduces the ambiguity of the brackets "[]" in JavaScript. Need friends can come to the reference, I hope to help you
JavaScript brackets have four semantic semantics 1, declaring the array code as follows: var ary = []; Declares an empty array var ary = [1,3]; Declare an array, assign the initial value semantics 2, and take the array member code as follows: var ary = [1,2,3]; var item = ary[0]; Semantic 3, defines the object member (which can not follow the identifier rules) code as follows: var obj = {}; Adding a property to obj Name,name is a valid identifier, that is, you can also define obj[' name ' = ' Jack ' by Obj.name method; Adding a property to obj 2a,2a is not a valid identifier (cannot begin with a number) and cannot be defined by obj.2a to define obj[' 2a ' = ' test '; Semantic 4, take the object member code as follows: var obj = {name: ' Jack '}; obj[' 2a '] = ' test '; obj[' name ']; --> Jack obj[' 2a ']; --> test (not available through obj.2a)