17

Just JavaScript things:
alert(typeof NaN); //alerts 'Number' alert(NaN === NaN); //evaluates false
What else would you expect?

Comments
  • 0
    So would that mean `alert((typeof NaN) === (typeof 1)); // true`?

    I do remember some weird behavior with `NaN`. Just never cared to attempt this.
  • 3
    NaN is not equal to anything and that makes sense imo. If you want to check for NaN use isNaN()
  • 1
    @nicholai To be fair, you should never get a NaN value in my opinion.

    Most other languages would not compile or throw exceptions, and there's no reason not to apply a similar strict style to js. Check whether a value is zero before dividing, whether a number is negative before taking a square root — instead of after it.
  • 0
    @bittersweet i dont think thats a language issue, the developer is at fault for not checking type input.
Add Comment