DEV Community


Discussion on: Dot notation vs Bracket notation

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!
samanthaming profile image
Samantha Ming Author

Good example! Thanks for sharing that đź‘Ť

Forem Open with the Forem app