51

I really like JS, but sometimes it's just incredibly stupid.
NaN stands for Not-A-Number

typeof NaN
> 'number'

why are you doing this to me

Comments
  • 3
    I was talking about this with a colleague and comparison to NaN should always result to false.

    edit: realised you weren't doing comparison at all.
  • 2
    It's not stupid. NaN is part of the number type specified in IEEE 754. Otherwise it wouldn't be possible, in languages with types, to specify that something is invalid/not a number/infinity/etc without another variable or flag.
  • 0
    NaN == NaN is false
    fuck this language
  • 4
    @Wiciaki yup just as specified in the standard. And getting false is the only result that could make sense. This is just gratuitous and ignorant bashing.
  • 2
    My desktop background just says "typeof(NaN) is the reason I have trust issues"
  • 0
    @willol Oh yes. I hate this type of bashing. Too few people are willing to to ask "why", instead skipping that part and directly start to rant.

    It's fine to rant if the reasons are rubbish but not if you're too lazy to do some research. ^^
  • 0
    JavaScript is like a theatrical show.

    Everything presented to you is not what it seems.
    Keep that in mind and you won't miss the required checks.

    Encapsulation by clever use of closures.
    Arrays are lists.
    Polymorphism and type casting.

    JavaScript is a brain teaser.
  • 0
    Favorited
Add Comment