JavaScript pop () method
Examples
Remove the last array element
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();
fruits.pop();
fruits resulting output:
Banana,Orange,Apple
try it"
Definition and Usage
pop () method is used to delete the last element of the array and returns the deleted element.
NOTE: This method changes the length of the array!
Tip: The first element of the array is removed, use the shift () method.
Browser Support
All major browsers support pop ().
grammar
array.pop()
return value
类型 | 描述 |
---|---|
所有类型* | The removed array item |
* Array element can be a string, number, array, Boolean, or other object types.
technical details
JavaScript version: | 1.2 |
---|