General JS Question Regarding Syntax


I have seen this used several times but do not know the official name or when it is ok to use it.


The question is regarding how you can take an object and use the brackets to get it’s properties. What is this called and when can and should it be used?


The name is bracket notation.

You are accessing the accounts property of the orion object.

You may use either:



to access the bar property of foo.

If foo has no bar property, it will return undefined.

Here is a Stack Overflow answer regarding bracket notation vs. dot notation.

Essentially, bracket notation allows you to use special characters when accessing an object’s property.


Thank you,

I know this was a very rudimentary question but , I had never really used
bracket notation until this point.

Thank you again.