I don't get JS sometimes...-

  • 1
    Welcome to Devrant!
  • 30
    To be fair, NaN is kind of a number to computers : the IEEE 754 norm defines 3 exceptions to the way numbers are represented by float, that is ±0, ±inf and NaN.
    So NaN is a legal value for a floating point number, and for once, JS is not to blame.
  • 5
    @CptFox thanks for clarification. i find it intuitive for nan to be a number-type value because it just doesn't make sense to me to return anything else while checking if it is a number.
  • 0
    There is no better meme to describe this.
  • 0
    @theofanis Sorry, but since we're talking JS, I'm really not sure we have the same 'this' (sorry, had to 😋)
  • 0
    @CptFox wow. Didn’t see that coming
  • 0
    @TeeSeal Too lazy to check, but since IEEE 754 defines NaN as "all floats with non-null mantissa and with exponent at maximum value", it could be that NaN1 != NaN2 because they are literally not the same value. Although it makes sense to say that even NaN1 does not equal NaN1, to be safe
Add Comment