Hacker News new | ask | show | jobs
by amptorn 1502 days ago
The more surprising thing about `Array.prototype.sort` is that it both sorts the array in place and returns the (now-sorted) array. You can go a long time writing `const arr2 = arr1.sort()` without realizing that what you're doing is wrong, and the code you're writing is misleading readers about what it does.