2 years ago

#13879

test-img

Mutaal Khan

Why does not NaN equal to NaN in JavaScript?

NaN (Not a Number).

  1. Why does not NaN equal(==) or strict equal(===) to NaN itself?
  2. How we can evaluate the following conditions to true?
let x = NaN;
// equal(==)
if(x == NaN) {
    console.log(`${x} (Not a Number)`);
}
// strict equal(===)
if(x === NaN) {
    console.log(`${x} (Not a Number)`);
}

javascript

numbers

nan

equality

0 Answers

Your Answer

Accepted video resources