What is the array.shift() method in JavaScript?

array.shift() is a method that removes the first element from an​ array and shifts the array to the left by one position.

The following slides illustrate how the method works:

1 of 5

array.shift() can be called on by any type of array. This method is very useful when the removal of the first element is required because it not only removes the first element; ​it also preserves the order of the rest of the array.

Implementation

The following code uses array.shift() ​​and shifts the array twice:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits);
fruits.shift();
console.log(fruits);
fruits.shift();
console.log(fruits);
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved