The pop()
method is used to remove items from inside the array.
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.
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.