While playing around in Chrome's dev console, I noticed something that I don't understand:
({})+""
evaluates to"[object Object]"
, as I expected{}+""
evaluates to0
(number)
Replacing {}
with {foo:"bar"}
in either expression doesn't change the result, so it does seem to be being parsed as an object literal. Replacing ""
with "42"
yields 42
, and replacing it with "foo"
yields NaN
.
What's going on here?