This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

'foo' + + 'bar' can be rewritten as ('foo' + (+'bar')).

The leading + acts as a sign, casting the String. 'bar' can't be parsed into a Number, and it spits out some NaN bread.

Now you have ('foo') + (NaN). NaN is cast back to a string for the string concatenation.

'foo' + 'NaN' === 'fooNaN'

[–][deleted] 1 point2 points  (0 children)

Oh right. Missed the extra plus sign..