top of page
Writer's pictureLearn JS

What Are JavaScript Array Methods: pop() vs push() vs shift() vs unshift() (Cheat Sheet Included)

Updated: Dec 19, 2022

With JavaScript arrays, you can store multiple values under one variable. One way to modify that information is by changing the variable it is stored on's value, but that will change the entire array. What if you just wanted to add/remove information at the start or at the end of an array? With JavaScript array methods, you can!


pop()

Removes an element at the end of an array.


push()

Adds new element(s) to the end of an array.


shift()

Removes an element at the start of an array.


unshift()

Adds new element(s) to the start of an array.


TL;DR: pop() removes an element at the end of an array. push() adds new element(s) to the end of an array. shift() removes an element at the start of an array. unshift() adds new element(s) to the start of an array.

Hey! I want you to know that feedback is appreciated! Yes, that includes your trash talk being highly critical about even the tiniest thing as long as your criticisms are valid. So if you can, please comment what you think about this post.

116 views1 comment

Recent Posts

See All

1 Comment


Guest
Sep 26, 2022

You got the job

Like
Image by Marjan Blan | @marjanblan

Be The First To Know

About new blog posts and updates

Thanks for signing up!

bottom of page