Confused about "" and [] when calling property

Hello there.

This is because the checkProp variable is exactly that - a variable.

obj.checkProp looks for the property checkProp in the object obj.
obj[checkProp] looks for the property with the value of checkProp in the object obj.

obj.checkProp is the same as obj["checkProp"].

Hope this helps

4 Likes