3 ms·
As someone who writes JavaScript full time, this is my biggest gripe with the language. Folks sorting arrays inline without first copying them is one of the thi
by bastawhiz 8y ago
As someone who writes JavaScript full time, this is my biggest gripe with the language. Folks sorting arrays inline without first copying them is one of the things that I pretty consistently call out in code reviews.
- TimJYoung 8y agoI'm sure that those cases are where you didn't want the mutation, but there are certainly performance and efficiency concerns that are directly satisfied by having the sorting operate on the original array. This is especially so when considering that such operations can be occurring in the UI thread (and not a web worker) where excessive computation can interfere with the responsiveness of the application.