14
bioDan
4y

The biggest code gag in JS:

typeof NaN === "number"

Comments
  • 2
    Blame IEEE 754 not Javascript
  • 2
    @brukernavn32 thanks for the info!
    I did wonder about the reasoning behind it..

    But I blame the language (JS or ECMAScript or the universe, multiverse and digital realms) about the semantics, and not on the implementation. I'm fine with the implementation :)
  • 1
    The implementation is also technically correct since the above mentioned standard defines NaN to be a floating point number 👍
  • 1
    @brukernavn32
    Lol i know 😂
    What i mean is the readability of the line.
    I.e.

    ".. is the type of 'Not a Number' must be equal to 'number' "

    and it returns true.

    That is a semantic flaw even if its a 100% technically correct description of the implementation.
  • 1
    > typeof null
    object
    > null instanceof Object
    false
Add Comment