Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:Array:pop

From MDC


Contents

[edit] Summary

Removes the last element from an array and returns that element. This method changes the length of the array.

Method of Array
Implemented in: JavaScript 1.2, NES 3.0
ECMA Version: ECMA-262 Edition 3

[edit] Syntax

pop()

[edit] Parameters

None.

[edit] Example

[edit] Example: Removing the last element of an array

The following code creates the myFish array containing four elements, then removes its last element.

myFish = ["angel", "clown", "mandarin", "surgeon"];
popped = myFish.pop();

[edit] See Also

push, shift, unshift