News for hackers. Stuff that matters.
Re:JavaScript in 2015 by squeaky-clean on Wednesday January 07, 2015 @10:57AM (#8851208)
There is no expected output. It doesn't make sense to subtract the value 1 from the string "wat". But Javascript will cast both of them to numbers, then try to subtract 1 from NaN. However, if you do "wat" + 1, Javascript will cast both of them to strings, and append "1" to "wat".

It's not just the odd behavior, but the inconsistency.

Re:JavaScript in 2015 by hfsktr on Wednesday January 07, 2015 @02:52PM (#8852845)
Ok that makes a bit more sense. I didn't even think about how it would be if you tried to add them.

I like javascript but I don't do anything so complicated (or maybe not the right types of things) that I run into many of these situations.