You can access the properties either...
Hence if the expression cool
has value 'name'
, then foo[cool]
is the same as foo['name']
or foo.name
.
The brackets also allow for...
1) more complex expressions like foo["data_"+variable]
to easily access fields named like data_something
,
2) property names that aren't simple identifiers, for example you could say foo["I'm long!"]
.
I hope this explanation brightens things up for you.