|
|
|
|
|
by rprospero
5289 days ago
|
|
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 |
|
It returns it because parseFloat("hello") = NaN, and NaN - 1 = NaN.