4 ms·
sort() is a bit weird, I have to agree, but the '==' thing is a common problem to a lot of languages, not exactly a js-specific WTF. Off the top of my mind: I
by Wilya 13y ago
sort() is a bit weird, I have to agree, but the '==' thing is a common problem to a lot of languages, not exactly a js-specific WTF.
Off the top of my mind:
In Python, '==' on arrays compares elements.
In Java, '==' on arrays compares the objects themselves. You have to use equals() to compare the elements.
In C(++) arrays, '==' compares the objects. But for std::vector, it compares the elements.
One could argue it's a language choice more than a screwup.
- arethuza 13y agoCommon Lisp has quite a few equality functions: eq, eql, equal, equalp http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node74.html http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node74.html
- hcarvalhoalves 13y agoThe point is not what "==" should do. The point is you have even two equality operators - with subtle differences - and still no way to compare two arrays by value without boilerplate, which should be trivial.