Dot Notation Vs. Bracket Notation
Dot Notation Vs. Bracket Notation
What are yall's opinions for these, pros and cons wise?
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Dot Notation Vs. Bracket Notation
I am assuming you are talking about languages like Javascript that mix arrays and objects, where you can use either dot notation (like an object) or bracket notation (like an array) to access members?
If you are, then I pretty much go with what seems to be the standard: use brackets when the member's name is not or may not be a proper JS identifier (such as starting with a number or including spaces). Use dot-notation for other members. Use brackets if you are using it like an array or list.
If you are, then I pretty much go with what seems to be the standard: use brackets when the member's name is not or may not be a proper JS identifier (such as starting with a number or including spaces). Use dot-notation for other members. Use brackets if you are using it like an array or list.
The indelible lord of tl;dr