4 ms·
In other words you’re concerned that some Array methods mutate the array (push, pop) and some don’t (map, concat)? If so then yeah, that can be annoying and/or
by zachrose 7y ago
In other words you’re concerned that some Array methods mutate the array (push, pop) and some don’t (map, concat)?
If so then yeah, that can be annoying and/or confusing.
- afandian 7y agoYes, it stems from arrays. But extends from there to any collection, built in or custom. Kind of bridges the built in type system but it's really about the expressivity of the language. It becomes especially important in React where you share objects up and down an immutable structure of objects.
- zachrose 7y agoYep. If you've bitten the apple of JavaScript tooling you can kinda sorta rig up compiler-enforced immutable data structures with TypeScript. But IMO if you're going that far it's much easier/well-documented to just use Elm or something.
- lkschubert8 7y agoFor me the worst is slice/splice.