Comment

Comment by amptorn

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.
parent amptorn 4 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton