Easy Tutorial
❮ Prop Dialog Open Prop Input Time Required ❯

JavaScript pop() Method

JavaScript Array Object

Example

Remove the last element of an array:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();

fruits output result:

Banana,Orange,Apple

Definition and Usage

The pop() method is used to remove the last element of an array and return that element.

Note: This method changes the length of the array!

Tip: To remove the first element of an array, use the shift() method.


Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
pop() 1.0 5.5 1.0 Yes Yes

Syntax

Return Value

Type Description
Any type Returns the removed element.

Array elements can be a string, number, array, boolean, or other object types.

Technical Details

| JavaScript Version: | 1.2 | | --- | --- |


More Examples

Example

const sites = ['Google', 'tutorialpro', 'Taobao', 'Zhihu', 'Baidu'];

console.log(sites.pop());
// Output result: "Baidu"

console.log(sites);
// Output result: ['Google', 'tutorialpro', 'Taobao', 'Zhihu']

sites.pop();

console.log(sites);
// Output result: ["Google", "tutorialpro", "Taobao"]

JavaScript Array Object

❮ Prop Dialog Open Prop Input Time Required ❯