Re:John Resig: JavaScript as a First Language
by maximusprime on Wednesday December 21, 2011 @03:55PM
(#3379095)
"hello" - 1 doesn't return NaN out of some sense of exception to trying to subtract from a string.
It returns it because parseFloat("hello") = NaN, and NaN - 1 = NaN.
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