JavaScript Array pop() Method

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();

Try It Yourself

Example 2

pop() returns the element it deletes:

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();   // Returns "Mango"

Try It Yourself

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

Manual:JavaScript Array.push() Method

Manual:JavaScript Array.shift() Method