Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"{} === null" throws syntax error in developer console [duplicate]

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

SyntaxError: Unexpected token ===

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

like image 687
mfreitas Avatar asked Dec 24 '13 00:12

mfreitas


1 Answers

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

({} === null)
like image 116
elclanrs Avatar answered Sep 24 '22 10:09

elclanrs