4 ms·
Yeah 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)
by PeCaN 11y ago
Yeah 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. ¯\_(·ω·)_/¯