This is done in Firebug:
>>> {a : 1} == {a : 1}
SyntaxError: syntax error
[Break On This Error] {a : 1} == {a : 1}
>>> ({a : 1}) == {a : 1}
false
So it needs to be ({a : 1}) == {a : 1}
, why is that?
Because {a : 1}
is a declaration and it's not allowed to be follow by ==
however
({ a : 1 })
is an expression and is allowed to be followed by ==
This is basically the rules defined in the grammer.
However note that ({ a: 1} == { a: 1})
is valid. So the equivalence expression is valid.
This means that {a : 1} == { a : 1 }
is simply not a valid statement.
12.4 of the ES5.1 spec says
NOTE An ExpressionStatement cannot start with an opening curly brace because that might make it ambiguous with a Block. Also, an ExpressionStatement cannot start with the function keyword because that might make it ambiguous with a FunctionDeclaration.
As a sidenote you will find that
({a : 1}) != {a : 1}
because they are two new objects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With