I am trying to understand the difference between .Notation and [] notation. In my problem below when I use if (object[key] === true) I get the correct answer. When I use if (object.key === true) it does not work. Could someone explain why it's different.
var myObj = { one: false, two: false, three: false, four: true, five: false, six: false }; var myFunc = function (object) { for (var key in object) { if (object[key] === true) { return "There is a true value in this object"; } else { } } return "Sorry, there are no true values in this object"; };
objectObject, so its better not to name the variables with the same name even if the case is different.