DEV Community

Discussion on: Dot notation vs Bracket notation

Collapse
 
marcellonicoletti profile image
Marcello Nicoletti

Another place bracket notation is useful is when you use a minifier. Minifiers can be configured to replace dot notation identifiers. This isn't an issue for most cases, but it is when you reference a DOM element's attributes. The value in the HTML will not get changed by minification so your references shouldn't either. Minifiers won't change strings so bracket notation using a string is how you can ensure DOM references work after minification.