English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The pop() method removes the last element from the array and returns the element...
This method changes the length of the array.
If this method is called on an empty arraypop(), it will returnundefined.
Note: IfTo delete the first element of the array, useshift()Method.
array.pop()
var fruits = ["Banana", "Mango", "Apple", "Orange"]; fruits.pop();Test and see‹/›
The numbers in the table specify the first browser version that fully supports the pop() method:
Method | |||||
pop() | 1 | 1 | Is | Is | 5.5 |
Return Value: | Returns the element removed from the array |
---|---|
JavaScript Version: | ECMAScript 1 |
Inpop()The method returns the value of "popped":
var fruits = ["Banana", "Mango", "Apple", "Orange"]; var x = fruits.pop();Test and see‹/›