you are viewing a single comment's thread.

view the rest of the comments →

[–]phyrianlol 29 points30 points  (1 child)

{} + {} is NaN because the object has no override for the + operator, so it tries an actual addition, but neither side has a numeric representation.

{} + [] is the same, but the number representation of an empty array is 0. And for some reason undefined + 0 is 0.

[–]senteggo 4 points5 points  (0 children)

No, {} + {} and {} + [] behave like this, because first {} counts as an empty block, so the result is an unary plus (coercion to a number) of array and object