If bracket notation and dot notation both output the same values, why would I use one over the other?


#1

Question

If bracket notation and dot notation both output the same values, why would I use one over the other?

Answer

A lot of times, bracket and dot notation can be used interchangeably (but keep it consistent in your code, so if you use dot notation, stick with it). However, bracket notation has some advantages over dot notation, and there will be cases when you may need to use bracket notation over dot notation. Go on to the next exercise to learn when and why.