JavaScript Array pop() Method
- Previous Page of()
- Next Page prototype
- Go to the Previous Level JavaScript Array Reference Manual
Definition and Usage
pop()
The method removes the last element of the array and returns it.
Note:pop()
The method changes the length of the array.
Tip:To delete the first element of the array, use shift()
Method.
Instance
Example 1
Delete the last element of the array:
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop();
Example 2
pop() returns the element it deletes:
const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop(); // Returns "Mango"
Syntax
array.pop()
Parameter
No parameters.
Technical Details
Return Value: |
Any type *, indicates the array item that is removed. * Array items can be strings, numbers, arrays, boolean values, or any other object types allowed in arrays. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
All browsers fully support pop()
Method:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Array
Tutorial:JavaScript Array Const
Tutorial:JavaScript Array Methods
Tutorial:JavaScript Sorting Array
Tutorial:JavaScript Array Iteration
- Previous Page of()
- Next Page prototype
- Go to the Previous Level JavaScript Array Reference Manual