Possible Duplicate:
JavaScript property access: dot notation vs. brackets?
Let’s consider I have an object:
var o = { x:1, y:2 };
What is the difference when I access a property like this:
o.x
Compared to this:
o["x"]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Those are called Member Operators, and there is a good bit of information on them in that link.
The only real differences are that the bracket notation allows you to disobey variable naming rules and do things like:
While the following is obviously a syntax error:
Also since bracket notation takes in a string you can use variables with it: