VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-array-pop-method/

⇱ JavaScript Array pop() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Array pop() Method

Last Updated : 16 Oct, 2025

The pop() method in JavaScript is used to remove the last element from an array and return that element. It modifies the original array by reducing its length by one.

  • It returns the removed element.
  • If the array is empty, it returns undefined.
  • It modifies the original array (does not create a new one).
  • The method does not accept any parameters.
  • It reduces the array length by one after execution.
  • Commonly used in stack implementations (LIFO-Last In, First Out).

Output
[ 'Apple', 'Banana', 'Mango', 'Orange' ]
removed string from array: Orange

Syntax:

arr.pop();

1. pop() on an Empty Array


Output
undefined
[]

The array is empty, there’s no element to remove, and the method returns undefined.

2. pop() in a Stack Implementation

The pop() method is often used in stack data structures to remove the top element (LIFO-Last In, First Out).


Output
30
20
[ 10 ]

Each call to pop() removes the last pushed element, just like removing items from a stack.

Comment