JavaScript Array pop() Method (original) (raw)

Last Updated : 11 Sep, 2024

The pop() method removes (pops) the last element of an array. The pop() method changes the original array.

It reduces the array's length by one and returns the removed element.

**Syntax:

arr.pop();

**Return value:

**Example 1: In this example, This function func() initializes an array arr, then removes and logs its last element using the pop() method.

JavaScript `

function func() { let arr = ['GFG', 'gfg', 'g4g', 'GeeksforGeeks'];

// Popping the last element from the array
console.log(arr.pop());

} func();

`

**Example 2: In this example this func() function initializes an empty array arr and attempts to remove the last element using the pop() method.

JavaScript `

function func() { let arr = [];

// popping the last element
let popped = arr.pop();
console.log(popped);

} func();

`

**Supported Browsers: