3 ms·
It's a good practice to have a way to compare objects anyway, and it should be standardized, like __hash__ in Python or hashCode in Java. Even a basic comparis
by sametmax 8y ago
It's a good practice to have a way to compare objects anyway, and it should be standardized, like __hash__ in Python or hashCode in Java.
Even a basic comparison between two nested arrays is work in JS, so we need articles like this for things we use day to day. It's weird that the orgs building the standard think that a common promise API is a priority, but a decent namespace system or a way to manipulate builtin datastructures without 3rd party lib isn't.
- arethuza 8y agoI would hate to have to debug a scenario where this type of comparison gives an incorrect result. I seem to remember the early days of Java where hashCode for string only looked at the first few characters - which had amusing results when storing URLs.
- sametmax 8y agoWell, I'm sure it can't be worse than debugging a code using == instead of ===: at least you can look at the implementation :)
- deleted 8y ago[deleted]