remove something from the end of an array with pop

pop is the opposite of push and will remove the last item in an array, it also returns the value so you can assign it to a variable

Javascript

var my_array = [ ["cat", 1], ["dog", 2],["fish", 3] ];
var my_array_item = my_array.pop();
console.log("the removed item: "+my_array_item);
console.log("the array: "+my_array);

Demo

Other Items in javascript
Page Views

This page has been viewed 70 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹