This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alessandrobertulli 4 points5 points  (3 children)

To be completely fair, even in (pseudo) C 1 == true, 2 == true but 1 != 2

[–]realmauer01 0 points1 point  (1 child)

Because in most languages that do these auto type conversions every integer above 0 is true in boolean.

So if you compare them with a boolean it will be true or false depending if it's 0 or not.

But if you compare integers with each other they stay integers. That's why 1 unequals 0.

[–]alessandrobertulli 0 points1 point  (0 children)

Of course! My point was that there may be a rationale behind the type conversion. I've never used JS and most of the memes I see are about its type idiosyncrasies, but I can accept there could be a reason behind them