6

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

SyntaxError: Unexpected token ===

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

user2864740
  • 60,010
  • 15
  • 145
  • 220
mfreitas
  • 2,395
  • 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
  • 92,861
  • 21
  • 134
  • 171