6

Why is it that when i type {} === null into the console it throws

SyntaxError: Unexpected token ===

null === {} gives me false as expected.

user2864740
  • 57,407
  • 13
  • 129
  • 202
mfreitas
  • 2,363
  • 3
  • 29
  • 42

1 Answers1

11

Because {} is treated as an empty block. You can wrap it in parentheses to force an expression:

({} === null)
elclanrs
  • 89,567
  • 21
  • 132
  • 165