That’s how it works, you need bracket notation when using a variable instead of a property name. The dot notation is only for the actual property name.
Bracket notation is useful if you have a property name that has special characters in it, like obj[“hello world!”] – such properties are often referred to as keys when accessed via bracket notation. The [ ] notation requires either a variable (explained next) or a string literal (which needs to be wrapped in " … " or ’ … ').
Of course, bracket notation is also useful if you want to access a property/key but the name is stored in another variable.