Mutating Array Methods

These methods are some of the first methods and are destructive by nature, meaning they alter the contents of the array without changing its reference. This can create issues in state management systems of libraries like React. They have corresponding copying array methods. Press → to see.

[🌑, 🌒, 🌓, 🌔].pop() [🌑, 🌒, 🌓]
[🌑, 🌒, 🌓, 🌔].push(🐈‍⬛) [🌑, 🌒, 🌓, 🌔, 🐈‍⬛]
[🌑, 🌒, 🌓, 🌔].reverse() [🌔, 🌓, 🌒, 🌑]
[🌓, 🌑, 🌔, 🌒].sort() [🌑, 🌒, 🌓, 🌔]
[🌑, 🌑, 🌑, 🌑].splice(1, 1, 🐈‍⬛) [🌑, 🐈‍⬛, 🌑, 🌑]
[🌑, 🌑, 🌑, 🌑].unshift(🐈‍⬛) [🐈‍⬛, 🌑, 🌑, 🌑, 🌑]
[🌑, 🌒, 🌓, 🌔].shift() [🌒, 🌓, 🌔]
[🌒, 🌓].forEach((🌑)=> 🌑+🐈‍⬛) [🌒🐈‍⬛, 🌓🐈‍⬛]