Rule Definition
Using NaN for comparison will produce unexpected results. Instead, the best way to see whether a variable is equal to NaN is to use Number.isNaN(), since ES2015, or (perhaps counter-intuitively) to compare it to itself. Since NaN !== NaN, when a !== a, you know it must equal NaN.
Remediation
Use Number.isNaN() instead .
Violation Code Sample
>>> if (test === NaN) { // violation
>>> return x === NaN // violation
>>> }
Fixed Code Sample
>>> if (Number.isNaN(test )) {
>>> return Number.isNaN(x)
>>> }
Reference
CISQ OMG ASCRM-CWE-252-data, ASCRM-CWE-704, ASCMM-MNT-20 recommendations
Related Technologies
Technical Criterion
CWE-704 - Incorrect Type Conversion or Cast
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.