Javascript null surprise

https://news.ycombinator.com/item?id=121508
by gruseom • 18 years ago
35 20 18 years ago

I just encountered this while tracking down a bug in some Javascript (verified in FF and IE):

   null < 0 || null == 0    -> false
but
   null <= 0    -> true
Would you expect that? I didn't. Obviously <= is implemented as !>. Time to look up all uses of <= and >= in my code...

p.s. Is this too trivial to post here? Too specialized? I'm curious.

Related Stories

Loading related stories...

Source preview

news.ycombinator.com