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
🌐
DebugEverything
blog.debugeverything.com › removing-the-last-3-elements-of-an-array-in-javascript
Removing the Last 3 Elements of an Array in JavaScript - DebugEverything
January 25, 2023 - The splice() method is used to add or remove elements from an array. To remove the last 3 elements from an array, you can use the splice() method in the following way:
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › splice
Array.prototype.splice() - JavaScript | MDN
If deleteCount is omitted, or if its value is greater than or equal to the number of elements after the position specified by start, then all the elements from start to the end of the array will be deleted. However, if you wish to pass any itemN parameter, you should pass Infinity as deleteCount to delete all elements after start, because an explicit undefined gets converted to 0. If deleteCount is 0 or negative, no elements are removed.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › pop
Array.prototype.pop() - JavaScript | MDN
// Returning what pop returns; that is // the removed element. return [].pop.call(this); }, }; collection.addElements(10, 20, 30); console.log(collection.length); // 3 collection.removeElement(); console.log(collection.length); // 2 ... This page was last modified on Jul 10, 2025 by MDN contributors.
🌐
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 - Using the reverse() MethodJavaScript ... the elements of the array in place. This method mutates the original array and returns the reversed array.JavaScriptlet a = [1, 2, 3 · 3 min read JavaScript - Delete last Occurrence from JS Array · These are the following ways to remove the last Item ...
🌐
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.
🌐
YouTube
youtube.com › tuts make
How to Remove the Last 2,3,4,N Elements from an Array in JavaScript - YouTube
In JavaScript, manipulating arrays is a common task, and there are various ways to remove the last 2, 3, 4, or N elements. This tutorial will explore simple ...
Published   December 14, 2023
Views   61
Find elsewhere
🌐
WebDevAssist
webdevassist.com › typescript › typescript-array-remove-last-element
How to remove the last element from an array in TypeScript
This method removes the last element of an array and returns that element. ... let givenArray = new Array(1, 2, 3, 4); console.log('Initial array:',givenArray); let lastElement = givenArray.pop(); console.log('Removed element:',lastElement); console.log('Final array:',givenArray);
🌐
Sentry
sentry.io › sentry answers › javascript › how can i remove a specific item from an array?
How Can I Remove a Specific Item from an Array? | Sentry
If the pop() or shift() methods won’t work for your purposes, you can select a method depending on whether you’ll identify the item by its value or its index. The pop() method removes and returns the last element of an array.
🌐
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?
The splice() method is used to add or remove elements from an array. The splice() method can change the original Array. The below-given syntax uses the splice() method to remove the last element of an array.
🌐
DebugEverything
blog.debugeverything.com › 3-easy-ways-to-remove-elements-from-javascript-arrays
3 Easy Ways to Remove Elements from JavaScript Arrays - DebugEverything
October 10, 2023 - Here we will discuss three different ways to solve this problem once and for all. Javascript already has a method to handle this, the pop() method. It removes the last element from the array, returns that element, and updates the length property.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › array › remove first or last n array elements
Remove the first or last n elements from a JavaScript array - 30 seconds of code
December 24, 2023 - This time around, we'll use Array.prototype.findLastIndex() to locate the last element matching the predicate function. Once we have the index, we can use the same technique as before to return a new array with the appropriate elements removed. const dropLastUntil = (arr, func) => { const index = arr.findLastIndex(func); return arr.slice(0, index >= 0 ? index + 1 : arr.length); } dropLastUntil([1, 2, 3, 4], n => n < 3); // [1, 2] JavaScript ·
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
Popping items out of an array, or pushing items into an array. The pop() method removes the last element from an array:
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
Note: pop() can only be used to remove the last item from an array. To remove multiple items from the end of an array, see the next example. This example uses the splice() method to remove the last 3 items from the fruits array.
🌐
Delft Stack
delftstack.com › home › howto › javascript › remove last element from array in javascript
How to Remove Last Element From Array in JavaScript | Delft Stack
February 2, 2024 - Check the code below. var array = [10, 11, 12, 13, 14, 15, 16, 17]; array.splice(-1, 1); console.log(array); ... The pop() function is the most straightforward way to achieve this.