JavaScript » Array » pop

Syntax:
Array.pop()

The pop method is used to remove and return the last element of an array. This affects the length of the array.

Examples

Code:
cars = ["Mercedes", "Ford", "Chrysler"]
document.write(cars.pop())
Output:
Chrysler
Explanation:

This example creates an array called 'cars' with the listed elements, and the pop method then removes and returns the last element "chrysler" leaving just the two elements "Mercedes" and "Ford" in the array: