This is a bit complicated. This happens because most JavaScript engines interpret {} as a code block, not an object. So {}+1 is essentially the same as +1 . If you do (for example)
({}+1})
then the code inside the brackets () will be interpreted as an expression, not a block of code. Thus, {} becomes the actual object.
Read this for more details:
http://www.2ality.com/2012/01/object-plus-object.html
The article also explains why it is different from Node.Js.
source share