Array.prototype.pop

Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.

Syntax

pop()

Return value

The removed element.

Example

var drinks = ["coffee", "tea", "water"]
print("Removed element:", drinks.pop())
print("Array now contains:", drinks)
Removed element: water
Array now contains: coffee,tea

See also