Seeing this question: Is there a (built-in) way in JavaScript to check if a string is a valid number? and this: jsperf, one of the presented approaches is this (mutatis mutandis
+ converts the value to a number.
+
a gets converted to 123 and 123 === 123.
a
123
123 === 123
b gets converted to NaN but NaN !== NaN (because NaN is never equal to another NaN according step 4a of the equality rules).
b
NaN
NaN !== NaN