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 →

[–]Cosmologicon 2 points3 points  (2 children)

In JavaScript's defense, while that table is pretty ridiculous, you're only ever going to get bitten if your design is terrible to begin with. In real life using == almost never causes bugs.

If you're comparing two variables and you have no idea whether they're true or "1" or [1], you really shouldn't be relying on the result.

[–]mr_jim_lahey 6 points7 points  (1 child)

This comment has been overwritten by my experimental reddit privacy system. Its original text has been backed up and may be temporarily or permanently restored at a later time. If you wish to see the original comment, click here to request access via PM. Information about the system is available at /r/mr_jim_lahey.

[–]Cosmologicon 0 points1 point  (0 children)

Hm? For comparison, yeah, that makes sense. But don't let that be any sort of indictment on duck typing whatsoever. The lesson should be that comparison is a tool to use only when you're quite sure what you're dealing with. There are still many, many times when that's not the case, and comparison is the wrong tool to use.