The difference between variable and attribute names

  First thing clear: attribute name of an object can only be strings and numbers, variable represents the value they represent.

   

 

  It can be seen from the exemplary access object attribute name only a string or a number, but not other. You can also be a string or number assigned to a variable, then access via variable, because the variable is represented by its corresponding value of.

 

  for in the cycle, key object property name rather than variable, access attribute values ​​obj [key], or not obj.key obj [ "key"]

Guess you like

Origin www.cnblogs.com/angle-xiu/p/11314531.html