Home JavaScript Array Methods pop() JavaScript Array pop() Method Definition Array.prototype.pop() removes the last element, shortens length by one, and returns that element. It mutates the array in place — the opposite end of push() .
array.pop()
removes last element
returns that element
empty [] → undefined
mutates array · length decreases
pair with push() → LIFO stack Syntax Call array.pop. Start with this line.
Call What it does array.pop()Primary signature. array.pop(...)Call with the arguments your case needs.
Built into JavaScript. Call pop(...) on an array instance — no import required.
Library declarations Parameters Parameter Description Array Required. Target to shorten
Return Value Return Value Description * Removed element, or undefined
JavaScript Examples 1. Remove last 2. Empty array 3. Stack LIFO Example 1 — Remove the Last Element Pop "yellow" from a color list and keep the rest.
const colors = ["red", "green", "blue", "yellow"];
const removed = colors.pop();
console.log(removed);
// "yellow"
console.log(colors);
// ["red", "green", "blue"] yellow
["red","green","blue"] How It Works Start with four colors. Last index is "yellow".Call pop(). That last value is removed and returned.Capture the return. removed holds "yellow".Array shrinks. colors now has three items — mutated in place.Example 2 — Empty Array Returns undefined Popping [] does not throw — you get undefined.
const empty = [];
const result = empty.pop();
console.log(result);
// undefined
console.log(empty.length);
// 0 How It Works No elements to remove. Length is already 0.Return is undefined. Same as reading a missing slot.Array stays empty. Length remains 0.Guard when needed. Check arr.length if empty should be an error.Example 3 — Stack with push() and pop() Last item pushed is the first one popped (LIFO).
const stack = [];
stack.push("first");
stack.push("second");
stack.push("third");
console.log(stack.pop()); // "third"
console.log(stack.pop()); // "second"
console.log(stack);
// ["first"] How It Works Push builds the stack. Items land at the end: first → second → third.First pop. Removes "third" (last in).Second pop. Removes "second".LIFO pattern. Remaining stack is ["first"].Compatibility
Browser & Runtime Support Array.prototype.pop() is one of the oldest array methods, available since JavaScript 1.2 / ES3 .
✓ Baseline · ES3
Array.prototype.pop() Supported in every browser ever shipped with JavaScript arrays, including Internet Explorer, and all Node.js versions.
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support Array.pop() Universal
Bottom line: Safe to use in any environment. No polyfill needed.
Frequently Asked Questions What does Array.pop() do? pop() removes the last element from an array, shortens length by one, and returns that removed element.
Does pop() mutate the original array? Yes. pop() changes the array in place by removing the final element and updating length.
What does pop() return on an empty array? undefined. The array stays empty and length remains 0.
How is pop() different from push()? push() adds to the end; pop() removes from the end. Together they implement a LIFO stack.
How is pop() different from shift()? pop() removes from the end. shift() removes from the start (and is usually slower on large arrays).
Which browsers support pop()? pop() has been available since JavaScript 1.2 / ES3. It works in every browser, including very old ones.
Next: push() Learn how to append one or more elements to the end of an array.
push() tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
14 people found this page helpful
Helpful Share Copy link Suggestion