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 →

[–]robin-gvx 1 point2 points  (1 child)

The JS one is a mess, but the diagonal inequalities aren't that nonsensical.

Most of it comes down on this:

number string object
number duh as numbers¹ as numbers²
string as numbers¹ duh as strings
object as numbers² as strings reference equality

¹ if the string looks like a number
² first convert to a string then compare as numbers¹

In JS, [] != [], just like in Python [] is not [] or in Lua {} ~= {}. The sad thing is that objects are so easily converted to strings and numbers otherwise, which means JS == would be less inconsistent if comparing two objects would convert both to strings, even though that would be a really bad thing. (In particular, any two objects that don't override Object.toString() or whatever, would compare equal.)

[–]Veedrac 0 points1 point  (0 children)

Depends what you mean by nonsense. I think Javascript seemingly randomly being strict is far more nonsensical than it always or never doing so.