Adding and Removing
There are a variety of standard library methods for modifying the contents of arrays. In this section, we'll look at:
push
pop
shift
unshift
splice
Adding and Removing Elements
To add or remove from the end of an array, we use push
and pop
.
To add or remove from the front, we use shift
and unshift
.
Inserting and Deleting
We can use splice
to insert or delete elements from any part of the array.