JavaScript Array.prototype.pop() Method
The pop() method removes the last element from an array and returns it, changing the array's length.
Description
The pop() method removes the last element of an array and returns it. It changes the array in place. Together with push(), it lets you use an array as a stack (last in, first out).
To read the last element without removing it, use at(-1).
Calling pop() on an empty array is safe and returns undefined, but that's indistinguishable from popping an element whose value is undefined, so check length first if it matters. It's fast because no other elements need to move, unlike shift(), which removes from the start.
Syntax
array.pop()Return Value
The removed element, or undefined if the array was empty.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.pop() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





