3 ms·
Because python is broken in this respect -- JS engines do exactly the same object optimisations and get comparisons correct.
by olliej 8y ago
Because python is broken in this respect -- JS engines do exactly the same object optimisations and get comparisons correct.
- loeg 8y agoMeh. They're different languages with different expectations. "is" is distinct from "==" in both, and Python gets "==" right (obviously). Javascript doesn't really have any high ground here[0]. (In contrast, Python:) >>> [] == False False >>> object() == False False >>> "" == False False >>> {} == False False They're just different. [0]: https://www.youtube.com/watch?v=et8xNAc2ic8 https://www.youtube.com/watch?v=et8xNAc2ic8
- viraptor 8y agoJS has "strict equality" comparison. It's not the same as "identity" comparison.