44 ms·
Except for + and == isn't that true of most operators in JS?
by emodendroket 11y ago
Except for + and == isn't that true of most operators in JS?
- PeCaN 11y agoYeah that's kind of the problem, those happen to be the two most commonly used operators. All the other arithmetic operators try to convert too ('5' - 3 === 2), but at least produce NaN if the arguments can't coerce to numbers (an exception would be better IMO, but whatever). Bitwise operators consider non-numeric strings to be 0, not NaN, presumably because JavaScript bitwise operands are always considered to be signed 32-bit ints. Apparently ~'js' isn't a TypeError. ¯\_(·ω·)_/¯