3 ms·
I think the classic example is [] == ![] evaluates to true. It’s not absurd logically, just the operators act weirdly/non-standardly.
by camjw 6y ago
I think the classic example is [] == ![] evaluates to true. It’s not absurd logically, just the operators act weirdly/non-standardly.
- mirekrusin 6y agoYeah, that one is funny > [] == [] false > [] == ![] true
- mirekrusin 6y agoHowever typescript says: This condition will always return 'false' since the types 'never[]' and 'boolean' have no overlap. ...for `[] == ![]`. Which is ironic because it does return true, not false. However at least it flags an error! I wonder how much of weirdness is wiped out by linters/ts/etc.
- qsort 6y agoHonestly that's more of a weirness of the '==' operator, which is kind of deprecated in modern JS. On the other hand I fully agree that non-strict definitions of equality are bound to generate weird cases around nullish values.