Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Arrays!
You have completed JavaScript Arrays!
Preview
JavaScript provides the pop() method for removing elements from the end of an array, and shift() for removing elements from the beginning.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
They let you add one or more elements
to the end or beginning of an array.
0:00
JavaScript also provides two methods for
removing elements from the end or
0:00
beginning of an array,
they're called pop and shift.
0:04
The pop method is like
the opposite of push.
0:08
While push pushes an element
to the end of the array,
0:11
pop pops the item off the end, and
shift is like the opposite of unshift.
0:14
It removes the first
element from an array.
0:19
Let's revisit the shoppingList array and
run the pop method on it.
0:22
The last item, coffee,
gets removed by pop.
0:26
Now the shoppingList array
holds three elements.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up