When trying to access the property a of the object {}
{}.a
I get the error
SyntaxError: Unexpected token .
With parens all is fine:
({}).a
Why do I get an error in the fist place? Is there ambiguity?
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.
The curly braces are interpreted as a block statement, not as an object literal. You cannot begin an expression statement with a left curly brace.
The specification states:
Source: http://es5.github.com/x12.html#x12.4