Tcobb;1214074 wrote:An object property can only be accessed by the "dot" notation if its name conforms to the rules concerning valid names for javascript variables. In your case, a variable that begins with '5' is illegal as a js variable name.
However, with the square bracket notation the property name doesn't have to conform to the naming conventions. That's what is happening. An object can be given some property names that cannot be accessed by the "dot" method.
:o thanks Tcobb...but I don't know why this is illegal.
I am reading <javascript: the definite guide>section7.3
[INDENT]Section 7.3. Objects as Associative Arrays
You've seen the . operator used to access the properties of an object. It is also
possible to use the [] operator, which is more commonly used with arrays, to
access these properties. Thus, the following two JavaScript expressions have the
same value:
object.property
object["property"]
The important difference to note between these two syntaxes is that in the first,
the property name is an identifier, and in the second, the property name is a
string. You'll see why this is so important shortly. [/INDENT]