Without a surrounding parenthesis, {}
would be considered as an empty code block
in javascript. =
followed by a code block
would be an invalid syntax. That is why you are seeing an error there.
If you wrap it inside of a parenthesis like ({} === {})
, then it would be considered as an expression
and it will be evaluated to false as both are referencing two different objects.
The following example may give you a clear picture about it,
{ var x = 5; console.log(x); } == 2
// will throw the same error that you are facing.