Multiple choice technology web technology

To what value will the following expressions evaluate in the JavaScript console? NaN == NaN

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In JavaScript, NaN (Not-a-Number) is a special value that is never equal to itself, even when compared with == (loose equality). This is by design according to the IEEE 754 floating-point specification. Therefore, the expression NaN == NaN evaluates to false. To properly check for NaN, you should use the isNaN() function or Object.is(NaN, NaN).