Why is the result of the expression {}+[]
0
?
It appears that the +
is treated as a unary operator instead of a normal addition operator. The expression then becomes {}0
. Why is this valid JavaScript and why is the result 0
? Why is the object literal in the expression ({})+[]
treated normally?
Note: I tried searching for a similar question in SO but it doesn't look like searching using symbols works.