Retrieving Data
We have 2 choices: bracket and dot notation
There are certain rules to follow:
- You cannot use dot notation if the property starts with a number
someObject.1blah = INVALID
someObject["1blah"] = VALID
- You can lookup using a variable with bracket notation
someObject.str = doesn't look for "name"
someObject[str]= does evaluate str and looks for "name"
- You cannot use dot notation for property names with spaces
someObject.fav color = INVALID
someObject.["fav color"] = VALID
Open Console to view code