3 ms·
For what it's worth, there are only two, maybe three methods in that entire list that mutate where it's not obvious: sort, reverse, and (maybe) splice. All the
by Ajedi32 7y ago
For what it's worth, there are only two, maybe three methods in that entire list that mutate where it's not obvious: sort, reverse, and (maybe) splice. All the other methods (like push, pop, fill, etc) are methods whose entire purpose is to mutate the array.
- rgoulter 7y agoThat was my first impression. But then the same logic applies to concat. ("I want to add another array").
- erikpukinskis 7y agoSometimes I don’t. Actually usually I don’t, I do a lot of [].concat(a, b).