ScanSkill

pop

The pop() method is used to remove items from inside the array.

Syntax

array.pop()

The pop() method attaches to the right side of an array with the . operator. The pop method removes item from the right side of the array.

Example

const fruits = ['apple', 'mango', 'banana'];

fruits.pop();

console.log(fruits); // Prints: [ 'apple', 'mango' ]

fruits.pop();

console.log(fruits); // Prints: [ 'apple' ] 

We can see that the pop() method removes an item from the end of the array.