Array.prototype.pop() by JavaScript convention.

let fruit = ['apple', 'orange', 'banana', 'tomato'];
let popped = fruit.pop();

console.log(popped); // "tomato"
console.log(fruit); // ["apple", "orange", "banana"]

Answer from Stuart Kershaw on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › splice
Array.prototype.splice() - JavaScript | MDN
Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable. js · const myFish = ["angel", "clown", "mandarin", "sturgeon"]; const removed = myFish.splice(2, 0, "drum"); // myFish is ["angel", "clown", "drum", "mandarin", "sturgeon"] // removed is [], no elements removed ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › pop
Array.prototype.pop() - JavaScript | MDN
In case you want the value of this to be the same, but return a new array with the last element removed, you can use arr.slice(0, -1) instead. The pop() method is generic. It only expects the this value to have a length property and integer-keyed properties. Although strings are also array-like, ...
🌐
Medium
medium.com › @iamdarius › 4-ways-to-remove-the-last-element-from-an-array-in-javascript-17749b12be0c
Learn 4 Ways to Remove the Last Element from an Array in JavaScript | by Darius Moore | Medium
September 8, 2022 - Splice is a powerful method that can be used to add new elements to an array, remove elements from an array, or perform both actions simultaneously. Unlike slice, splice mutates the original array that it is being invoked on. Below, the start count (the first parameter) is given an argument of -1, and the delete count (the second parameter), is 1. These two arguments indicate that the delete operation will begin at the last element of the array, and will only delete one item, respectively.
🌐
Jaketrent
jaketrent.com › post › remove-array-element-without-mutating
Remove an Array Element Without Mutation
We could simply do that: create a new array (a clone of the original) and mutate that instead of the original. To do this, we could use a clone function or the spread operator (...) to copy the original array into a whole new array, the splice just the new array.
🌐
GitHub
github.com › kolodny › immutability-helper › issues › 78
how to use immutability-helper remove elements from array · Issue #78 · kolodny/immutability-helper
September 26, 2017 - var state = [{name:'a'},{name:'b'},{name:'c'},{name:'d'}]; var indexToRemove = state.findIndex(item => item.name === 'c'); var newState = update(state, {$splice: [[indexToRemove, 1]]}); console.log(newState); // [{name: "a"}, {name: "b"}, {name: "d"}]``` if i have a list var list=['a','c'], how to remove two elements from array 'state'
Published   Dec 18, 2017
🌐
Agney
agney.dev › blog › immutable-array-operations
Immutable Array Operations - JavaScript | Blog
October 5, 2019 - Adds one or more elements to the beginning of an array and returns the new length of the array. ... removes the last element from an array and returns that element.
Find elsewhere
🌐
DEV Community
dev.to › jsdevspace › 9-ways-to-remove-elements-from-arrays-in-javascript-4be6
9 Ways to Remove Elements from Arrays in JavaScript - DEV Community
August 6, 2024 - Using spred operator allows you to handle array element removal in a functional and immutable way, maintaining clean and readable code.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-remove-n-elements-from-the-end-of-a-given-array-in-javascript
JavaScript - Remove n Elements From End Array - GeeksforGeeks
January 11, 2025 - Reducing the length property of the array truncates its elements. This method modifies the array if used directly, so a copy is recommended. Use slice() or filter() for immutable operations.
🌐
HackerNoon
hackernoon.com › how-to-remove-the-last-element-of-a-javascript-array
How to Remove the Last Element of a JavaScript Array | HackerNoon
November 6, 2022 - One of the most frequent operations we perform on an array is removing the last element. There are a few different ways to do this - but one of the most common
🌐
Ultimate Courses
ultimatecourses.com › blog › remove-specific-item-from-array-javascript
Removing Items from an Array in JavaScript - Ultimate Courses
Array.prototype.indexOf() will return -1 if the element is not found so I’d recommend a safety check around this. You’ll notice I’ve also added const removedDrink. This is because .splice() returns us the removed item(s): // ["Coffee"] console.log(removedDrink); // ["Cola", "Lemonade", "Water"] console.log(drinks); ... So now we understand a little more about mutable and immutable, let’s uncover the immutable pattern to “remove” an element from an array.
🌐
W3Schools
w3schools.com › jsref › jsref_pop.asp
JavaScript Array pop() Method
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion · ❮ Previous JavaScript Array Reference Next ❯ · Remove (pop) the last element: const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop(); Try it Yourself » ·
🌐
CoreUI
coreui.io › answers › how-to-remove-the-last-item-from-an-array-in-javascript
How to remove the last item from an array in JavaScript · CoreUI
September 18, 2025 - The pop() method is highly optimized for removing from the end, making it the preferred choice over alternatives like slice(0, -1) when you need to mutate the original array. ... Follow Łukasz Holeczek on GitHub Connect with Łukasz Holeczek ...
🌐
Tutorial Reference
tutorialreference.com › javascript › examples › faq › javascript-how-to-remove-last-element-from-array
How to Remove the Last Element from an Array in JavaScript | Tutorial Reference
Non-mutating (Immutable): Creates a new array with the desired changes. The original array is left untouched. This is the recommended best practice in modern JavaScript as it leads to more predictable and less error-prone code. Mutating: Modifies the original array in place.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-delete-last-occurrence-from-js-array
JavaScript - Delete last Occurrence from JS Array - GeeksforGeeks
July 11, 2025 - The array length property in JavaScript ... arrays. To remove the last element from an array, you can use the spread operator along with array destructuring....
🌐
TutorialsPoint
tutorialspoint.com › how-to-remove-last-array-element-in-javascript-and-return-it
How to remove last array element in JavaScript and return it?
We have learned two methods, using which we can remove the last array element in JavaScript. Among these methods, pop() is the easiest way to remove the last element of an array.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › pop
JavaScript Array pop() - Remove Last Element | Vultr Docs
December 9, 2024 - The pop() method is a fundamental array operation in JavaScript, designed to remove the last element from an array.