4 ms·
I think it's a lot less nasty than the Python version. At least the JS version only gives you a weird answer if you're comparing a number to a string, while Pyt
by hn_throwaway_99 4y ago
I think it's a lot less nasty than the Python version. At least the JS version only gives you a weird answer if you're comparing a number to a string, while Python will automatically do a weird type conversion even if you're just comparing two "number looking strings" to begin with.
Edit: I'm an idiot, thanks for the responses for correcting me, was thinking PHP but had Python on the brain I guess. Original bad edit: I was downvoted pretty hard, but I think I was just unclear. In Python, doing md5("foo") == md5("bar") returns true because Python converts both strings to numbers first because they have an e in them. That is, in my opinion, Python is doing an unnecessary conversion there that JS doesn't do in that case. See https://stackoverflow.com/questions/12598407/why-does-php-convert-a-string-with-the-letter-e-into-a-number https://stackoverflow.com/questions/12598407/why-does-php-co...
- cochne 4y agoPython doesn’t do any automatic type conversion for strings
- hn_throwaway_99 4y agoThat's false, and that's the point I was trying to make, albeit unclearly - see https://stackoverflow.com/questions/12598407/why-does-php-convert-a-string-with-the-letter-e-into-a-number https://stackoverflow.com/questions/12598407/why-does-php-co...
- andreareina 4y agoThat's about PHP
- blep_ 4y ago... no? Python's == never does implicit type conversions unless one of the types overrides it to do so (neither str nor int does)
- mjw1007 4y agoI think you keep writing "Python" when you intended to write "PHP".
- hn_throwaway_99 4y agoLol, thanks, I'm an idiot, it was the brain fart that kept going.