Rule: use-isnan

Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.

Rationale

Since NaN !== NaN, comparisons with regular operators will produce unexpected results. So, instead of if (myVar === NaN), do if (isNaN(myVar)).

Config

Not configurable.

Config examples
"use-isnan": true
Schema
null

Code examples:

Enforces usage of `isNan()`.
"rules": { "use-isnan": true }
Passes
if (isNaN(parseInt('_4711'))) {
    doSomething();
}
Fails
if (parseInt('_4711') === NaN) {
    doSomething();
}