Comment

Comment by rprospero

Except, not "everyone" would expect that.

I'd expect "hello" - 1 to return NaN, since you can't perform numerical subtraction on something that isn't a number. That's exactly what Javascript does.

In the same way, I'd expect "hello" + 1 to return Nan, since you can't perform string concatenation on something that isn't a string, and you can't perform numerical addition on something that isn't a number.

Edited for clarity

parent rprospero 15 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton