Javascript - Removing Elements (pop, shift)
📖 Read the lesson
Code Life
By Pierre Marsaa
Removing the Last: pop
pop()
does the opposite of
push()
: it removes the last element. And it gives it back to you, so you can use it:
↗️
Loading editor...
↶
▶️ Run
↷
The array now has 2 elements, and
used
holds the one that was removed. No argument needed:
pop
always takes the last one.
Verify