Page 1 of 1

Dot Notation Vs. Bracket Notation

Posted: Thu Nov 14, 2013 3:56 pm
by Mardonis
What are yall's opinions for these, pros and cons wise?

Re: Dot Notation Vs. Bracket Notation

Posted: Thu Nov 14, 2013 10:05 pm
by Jackolantern
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.