JavaScript concept with a cup of coffee and a laptop

Array Methods & Properties

Pop

Pop allows us to remove the last item in an array. If we execute the following code from the last post’s array…

baseballCards.pop();
console.log( baseballCards );

The output will be ‘Aaron’, ‘Ruth’, ‘Wagner’.

There might be times you wish to remove an item from an array, but still keep it for some usage. We can store it in a variable…

let backRowCatcher = baseballCards.pop();
console.log( backRowCatcher );

The output will be Uecker given our original added array.

Happy Coding!

Clay Hess

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Skip to content