News for hackers. Stuff that matters.
Re:JavaScript: The Curious Case of null >= 0 by TheRealPomax on Saturday September 09, 2017 @01:43PM (#15208155)
the problem is there is no "right" until you define what right means, which is where the spec comes in. These results are "right", if unexpected, and the true issue here is of course not so much the mathematical results between the three tests, but the fact that JS gives you the freedom to compare anything to anything, irrespective of whether that comparison makes sense at all. Python allows this in a few places, too, with equally bizarre results (see another comment that highlights a few of them).

While tempting to do so, thinking of >= as implying "> or ==" is simply not true in any language that performs type coercion to get around type incompatibility issues.

There are no comments on this comment yet.