﻿# V7011\. Comparison with 'NaN' is incorrect\. Use 'isNaN\(\)' or 'Number\.isNaN\(\)' method instead\.

The analyzer detected that a value is compared with NaN using a binary operator\. Since NaN in JavaScript is implemented according to the IEEE 754 standard, comparisons with NaN that use \=\= or \=\=\=operators always return false\. Most likely, such a comparison in the code is a mistake\.

The example:

```cpp
let a = NaN;
console.log(a == NaN);  // false
console.log(a === NaN); // false

let b = "10"
console.log(b ==  NaN); // false
console.log(b === NaN); // false
```

The check always returns `false`, no matter which value is compared with `NaN`\. If the `!=` or `!==` operator is used for comparison, the result is always `true`\.

To check whether a value is `NaN`, use special methods [`isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN) and [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)\.

The fixed example:

```cpp
let a = NaN;
console.log(isNaN(a));        // true
console.log(Number.isNaN(a)); // true

let b = "10"
console.log(isNaN(b)); // false
Number.isNaN(b);       // false
```

Note the difference between these two methods in the example below\.

The `isNaN()` method returns `true` if the checked value is equal to `NaN` or becomes `NaN` after its conversion to a number\. The `Number.isNaN()` method does not convert the checked value to a number\. 

The example:

```cpp
console.log(isNaN("value"));        // true
console.log(Number.isNaN("value")); // false
```