Possible Duplicate:
Why {} != ( {} ) in JavaScript?
I tried it today and it threw me SyntaxError today and it made me wonder; what's wrong with this?
{} === {}
{} == {}
What's wrong?
Possible Duplicate:
Why {} != ( {} ) in JavaScript?
I tried it today and it threw me SyntaxError today and it made me wonder; what's wrong with this?
{} === {}
{} == {}
What's wrong?
When {
is the first token in a line, it's considered the start of block.
{
some();
statements();
here();
}
And not an object literal. A block of code cannot be equal to anything, it's not an assignable thing.
({}) === {}
That will set the parser straight.
Use parens. Parentheses turn the ambiguous code into an expression:
({}) === ({})
Or:
({} === {})