Array.prototype.pop()

Removes the last element from an array and returns it.

Since ES1 Spec ↗

Syntax

arr.pop()

Returns

any — The removed element, or undefined if the array is empty.

Examples

const a = [1, 2, 3];
console.log(a.pop(), a);
Output
3 [ 1, 2 ]
console.log([].pop());
Output
undefined

Notes

Mutates the array in place and shortens its length by one. Returns undefined for an empty array. Use `shift` to remove from the front instead.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also