Array.pop()

JavaScript 1.2+ Nav4+, NES3+ Syntax

							array.pop()

Description

The pop() method "pops" elements off the end of the array by deleting the last element of the array and setting the array's length property to one less than its current value. This last element is returned from the method. Table 6.11 shows the return value associated with this method.

Table 6.11. Arguments and Return Values Associated with pop()
Type Item Description
Returns The last element in the array is returned from the method.

Example

In Listing 6.51, an array of pages is created to represent a stack of papers. The pop() method removes and returns the top-most paper. After the pop() method is executed, the variable currentPaper contains "Page3", and the ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.