The easiest way is using shift(). If you have an array, the shift function shifts everything to the left.

var arr = [1, 2, 3, 4]; 
var theRemovedElement = arr.shift(); // theRemovedElement == 1
console.log(arr); // [2, 3, 4]
Answer from Thalsan on Stack Overflow
🌐
DEV Community
dev.to › dillionmegida › arrayshift-for-shifting-the-first-item-in-an-array-3lka
Array.shift() - for shifting the first item in an array - DEV Community
May 10, 2022 - It returns the first item and removes it from the array, thereby making the array lesser in length by 1. Here's how you achieve the previous result with shift: const array = [1, 2, 3, 4, 5] const shiftedValue = array.shift() console.log(shi...
Discussions

Why is removing a specific element from an array so needlessly complicated in Javascript?
You could use the .filter method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter Use it like this: const newArray = array.filter(element => element > 6) The 'element > 6' is just a placeholder example. If your array was a series of numbers, it would only return numbers that are greater than six. If you wanted it to remove a certain word from an array of words you could switch that conditional statement out with "element !== 'word' " 'newArray' will be your array without the value you're trying to remove. 'Array' represents the current array with the value you're trying to remove More on reddit.com
🌐 r/learnprogramming
9
0
January 17, 2023
Why is it that removing an element from the start of an array O(n) while at the end O(1)?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
8
2
September 16, 2023
🌐
Reddit
reddit.com › r/learnprogramming › why is it that removing an element from the start of an array o(n) while at the end o(1)?
r/learnprogramming on Reddit: Why is it that removing an element from the start of an array O(n) while at the end O(1)?
September 16, 2023 -

From my understanding the reason why removing the last element is O(1) is because you don't need to shift the array in memory. You simply remove the last element and leave the old space empty. So why is it that if you remove the first element that the Array HAS to to shift in memory (making it O(n))?

I don't understand the reasoning, if we are okay with leaving empty space in memory at the end of an array and not shifting all the other things surrounding the array in memory. Then why do we have to shift the array in memory if there is space that the start?

I am not understanding, if it's because the memory is trying to stay compact and no empty spaces are allowed. Then why don't all the other stuff in memory be shifted to the left after new space was cleared once we removed the last element from the array?

🌐
Codingem
codingem.com › home › how to remove the first element of an array in javascript
How to Remove the First Element of an Array in JavaScript - codingem.com
July 10, 2025 - Notice that the pop() function also returns the removed element. This might be useful in case you want to use the removed element later on in your code. To remove the first element of an array in JavaScript, use the shift() function.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › shift
Array.prototype.shift() - JavaScript | MDN
The shift() method shifts all values to the left by 1 and decrements the length by 1, resulting in the first element being removed. If the length property is 0, undefined is returned. The pop() method has similar behavior to shift(), but applied to the last element in an array.
🌐
Quora
quora.com › If-you-remove-the-first-item-in-an-array-in-JavaScript-does-the-second-item-in-the-array-automatically-become-the-first-one
If you remove the first item in an array in JavaScript, does the second item in the array automatically become the first one? - Quora
Answer (1 of 4): Yes, and the third becomes the second, the fourth becomes the third… there’s a BUNCH of work that the computer has to do… That’s why, if this is something that will need to happen often, it’s best to either flip the array around (store elements in the opposite order, so you’re r...
Find elsewhere
🌐
W3Schools
w3schools.com › jsref › jsref_shift.asp
JavaScript Array shift() Method
The shift() method removes the first item of an array. The shift() method changes the original array. The shift() method returns the shifted element. The Array unshift() Method · The Array push() Method · The Array pop() Method · array.shift() ...
🌐
Bennadel
bennadel.com › blog › 1796-javascript-array-methods-unshift-shift-push-and-pop.htm
Javascript Array Methods: Unshift(), Shift(), Push(), And Pop()
April 21, 2020 - The shift() method is like the pop() method, only it works at the beginning of the array. The shift() method pulls the first element off of the given array and returns it.
🌐
CoreUI
coreui.io › answers › how-to-remove-the-first-item-from-an-array-in-javascript
How to remove the first item from an array in JavaScript · CoreUI
September 18, 2025 - For performance-critical applications with large arrays, consider using slice(1) to create a new array instead of mutating the original, though shift() remains the standard choice for most scenarios. ... Follow Łukasz Holeczek on GitHub Connect with Łukasz Holeczek on LinkedIn Follow Łukasz Holeczek on X (Twitter) Łukasz Holeczek, Founder of CoreUI, is a seasoned Fullstack Developer and entrepreneur with over 25 years of experience. As the lead developer for all JavaScript, React.js, and Vue.js products at CoreUI, they specialize in creating open-source solutions that empower developers to build better and more accessible user interfaces.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Javascript array pop() function - JavaScript - The freeCodeCamp Forum
October 12, 2022 - In the following example i have used the following code but its not working. const myArray =[[“John”, 23], [“cat”, 2]]; i was ask to make myArray equals [[“John”, 23]]; after using pop() function on myArray . then make const ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › pop
Array.prototype.pop() - JavaScript | MDN
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, this method is not suitable to be applied on them, as strings are immutable. The following code creates the myFish array containing four elements, then removes its last element.
🌐
CoreUI
coreui.io › blog › what-is-javascript-array-pop-method
What is JavaScript Array.pop() Method? · CoreUI
March 18, 2024 - The original array is modified, ... consider copying the array before using pop(). Yes, you can use the shift() method to remove the first element of an array....
🌐
daily.dev
daily.dev › home › blog › get into tech › pop and push in javascript: array essentials
Pop and Push in JavaScript: Array Essentials
December 22, 2025 - Learn how to manipulate arrays with pop() and push() methods in JavaScript. Discover the basics of arrays, accessing elements, properties, and methods.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › shift-vs-pop-method-in-javascript
Shift() vs pop() Method in JavaScript - GeeksforGeeks
July 23, 2025 - ... <script> function func() { ... pop() method: The JavaScript Array pop() Method is used to remove the last element of the array and also returns the removed element....
🌐
CSS-Tricks
css-tricks.com › snippets › javascript › getting-first-and-last-items-in-array-and-splitting-all-the-rest
Getting First and Last Items in Array (and splitting all the rest) | CSS-Tricks
March 16, 2020 - So what’s the opposite of .pop()? (Please pause for light web searching…) Ah ha! It’s .shift()! const arr = ["This", "Little", "Piggy"]; const first = arr.shift(); console.log(first); // "This" (Note that arr[0] is probably the easiest way to get the first item, but play along here. Also, it’s kinda nice sometimes if what is cut off from the array remains an array so let’s keep looking…)
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › shift
JavaScript Array shift() - Remove First Element | Vultr Docs
November 25, 2024 - Start with a sample array. Apply the shift() method to remove the first element.
🌐
Mimo
mimo.org › glossary › javascript › array-pop
JavaScript Array pop() method: Syntax, Usage, and Examples
The pop() method in JavaScript removes the last element from an array and returns that element. It changes the original array by reducing its length by one. The JavaScript array pop method is often used when working with stacks, where the last item added is the first one removed (LIFO – Last ...