Accessing properties of an object by name simply requires the name to be added to the object reference with a dot separator between them.
However, the properties in an object are also kept in an array. You can access items in an array by index number. However, the objects are really accessed by name and so item 4 is really accessed as item "4". You can use the property names as symbolic names for an array index.
Now, assuming that we had deduced that the property we were interested in was stored in item 4 of the property array and had the name property4 as well, all of these would access the same property:
myObject.4
myObject.property4
myObject[4]
myObject["4"]
myObject["property4"]
See also: | Array index delimiter ([ ]), Property |
ECMA 262 edition 2 - section - 8.6.1
ECMA 262 edition 3 - section - 8.6.1
Wrox Instant JavaScript - page - 32
Prev | Home | Next |
Property attribute | Up | Property value |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |