Accessing values in Objects.
Dot Notation is converting the value to a string (string literal). Example: myObj.name;
is the same as myObj["name"];
and as we all know quotes define strings.
If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42;
myObj[num];
There are a few other limitations when accessing an object property. If the object key has a space or number in it, you cannot use dot notation.
var myObj = {