JavaScript

JavaScript

Made by DeepSource

Use double.IsNaN() to check if a double is NaN CS-W1003

Bug risk
Critical
Autofix

By specification, NaN is not equal to anything, not even itself. Therefore, comparing any double with NaN will always evaluate to false. The preferred and right approach is to directly use the double's .isNaN method.

Bad practice

var d = double.NaN;
d == Double.NaN;    // evaluates to false

Recommended

var d = double.NaN;
double.IsNaN(d);    // evaluates to true

References: