DEV Community

loading...

Discussion on: Dot notation vs Bracket notation

Collapse
clovis1122 profile image
JosĂ© Clovis RamĂ­rez de la Rosa • Edited

Great post, Samantha!

Another case where I would personally use bracket notation is when the property name is odd - that alerts the reader that the properties in the object are non-standard!

user.firstName;      // camelCase notation as usual.
user['first_name'];  // underscore notation, using brackets to remark that the name is different!
Collapse
samanthaming profile image
Samantha Ming Author

Good example! Thanks for sharing that đź‘Ť

Forem Open with the Forem app