In JavaScript, when adding a property to an existing object like this:
var qBacks = {
12: "Namath",
16: "Montana",
19: "Unitas"
};
qBacks["4"] = "Brett Favre"; //Will work!
qBacks.4 = "Brett Favre"; //Will not work!
//but
qBacks.player4 = "Brett Favre"//Will work.
and, if I want to append property 4 to remove the first name, I have to use bracket notation to complete:
qBacks[4] = "Farve"; //Works!
qBacks.4 = "Farve"; //Will not work!
Why won't the dot operator work with numbers to dynamically add properties or to modify the value? I am guessing it has something to do with typeof 4 being a primitive but would like to get better understanding. Thanks