We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Array.pop Redirect 1


The pop() method removes the last element from an array and returns that element.




The pop method removes the last element from an array and returns that value to the caller.

pop is intentionally generic; this method can be called or applied to objects resembling arrays. Objects which do not contain a length property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.

If you call pop() on an empty array, it returns an undefined value.


Example: Removing the last element of an array

The following code creates the myFish array containing four elements, then removes its last element.

var myFish = ["angel", "clown", "mandarin", "surgeon"];

console.log("myFish before: " + myFish);

var popped = myFish.pop();

console.log("myFish after: " + myFish);
console.log("Removed this element: " + popped);

This example displays the following:

myFish before: angel,clown,mandarin,surgeon
myFish after: angel,clown,mandarin
Removed this element: surgeon


Specification Status Comment
ECMAScript 3rd Edition Standard Initial definition. Implemented in JavaScript 1.2
ECMAScript Language Specification 5.1th Edition (ECMA-262) Standard  
ECMAScript Language Specification 6th Edition (ECMA-262) Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 5.5 (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,