3 ms·
> make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is con
by xigoi 3y ago
> make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed.
That… makes it even worse.
- slim 3y agowhy?
- xigoi 3y agoBecause now the behavior of comparison depends on whether the string looks like a number.
- chx 3y agoArguably 48 == "48" should be true. If this doesn't work for you, stick to ===.
- xigoi 3y agoThank you, I'll stick to languages where you can't just compare numbers and strings without an explicit conversion. Also, should 48 == "48.0" be true? How about "048", "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-eight"?