Need HELP in how to access an object property!

That’s because checkProp is a variable. In such case you can use only brackets.

However if you are using the actual property name then you can use dot notation as well.

var myObj = {
  top: "hat",
  bottom: "pants"
};
console.log(myObj.top) // hat
console.log(myObj['top']) // hat
1 Like