You could subtract one from the index and add the lenght to prevent negative values, get the reaminder with the length and take it as index for the element for mapping.

function shift(arr) {
    return arr.map((_, i, a) => a[(i + a.length - 1) % a.length]);
}

const b = [{ value: "" }, 8, "left"];

console.log(shift(b));

Answer from Nina Scholz on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › shift
Array.prototype.shift() - JavaScript | MDN
The shift() method of Array instances removes the first element from an array and returns that removed element. This method changes the length of the array.
🌐
W3Schools
w3schools.com › jsref › jsref_shift.asp
W3Schools.com
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion · ❮ Previous JavaScript Array Reference Next ❯ · Shift (remove) the first element of the array: const fruits = ["Banana", ...
Discussions

How to shift all the items in an array to the right(by 1) using method map?
Notice that the method above shifts the array in-place. If you need to keep the original array, you've to deep clone it first. More on stackoverflow.com
🌐 stackoverflow.com
How to use JavaScript Array.prototype.shift() - JavaScript Shift Explained with Examples
The JavaScript array method .shift() will remove the first element from an array and return that value. This will also change the length of the array Syntax var array = [1, 2, 3, 4]; array.shift(); Description .shift() will remove the element at index 0 of the array upon which it is called. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
5
June 23, 2019
Why are shift() and unshift() in JS in the wrong order? I'm learning, but this seems very wrong.
The only thing I can think is that "shift" is used in assembly language to mean "shift left" (roll moves right, in case you were wondering). So if you shift an array you slide everything over to the left. It's a pretty terrible name, IMHO. I'd do "pushfront" and "popfront", personally. More on reddit.com
🌐 r/learnprogramming
9
0
May 9, 2019
The four common Javascript array methods Push, Pop, Shift and Unshift
Great article! I think it’s important to note that working with the end of the array (push/pop) is more performant than the beginning (shift/unshift). The reason for this is that the array is indexed, so adding to the end of the array doesn’t require any additional time. Shift/unshift though require the whole array to be reindexed since you’re adding to the beginning. Performance isn’t important while you’re learning, and really only matters with large arrays, but it is a good concept to get used to early on. In programming, that’s noted with something called big O notation, which is just a formalized way to loosely note what’s going on in the code. Push/pop are what’s known as O(1)—pronounced “O of 1”—which means that it’s constant time, or the time of the method will always take the same amount of time no matter the length of the array. Shift/unshift are O(n)—pronounced “O of n”—which means that the length of time it takes depends on the number of items in the array. This isn’t to say that shift/unshift are bad. They are useful! Use them as you will. Write first, and then optimize later. More on reddit.com
🌐 r/learnjavascript
3
11
May 16, 2020
🌐
Mimo
mimo.org › glossary › javascript › array-shift
JavaScript Array shift: Syntax, Usage, and Examples
If you call shift() on an empty array, it does not cause an error; it simply returns undefined. Here’s the basic syntax: JSX · Open in Mimo · Open in Mimo · Copy Code · array.shift() It removes the first element of the array. It returns the removed element.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › shift-vs-pop-method-in-javascript
Shift() vs pop() Method in JavaScript - GeeksforGeeks
July 23, 2025 - Javascript Array shift() method: The JavaScript Array shift() Method removes the first element of the array thus reducing the size of the original array by 1.
🌐
DEV Community
dev.to › liaowow › is-javascript-s-shift-method-a-performance-boost-5df5
JavaScript Shift: Is JavaScript's .shift() Method a Performance Boost? - DEV Community
June 13, 2020 - Hey just to point out that shift itself is a bit of a pain doing it frequently - that's because a shift "might" have to move all of the elements in the array (it's not allocating fortunately) - it depends on the actual engine implementation - but it's likely.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
1 week ago - This example uses the splice() method to truncate the fruits array down to just its first 2 items. js · const fruits = ["Apple", "Banana", "Strawberry", "Mango", "Cherry"]; const start = 2; const removedItems = fruits.splice(start); console.log(fruits); // ["Apple", "Banana"] console.log(removedItems); // ["Strawberry", "Mango", "Cherry"] This example uses the shift() method to remove the first item from the fruits array.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › unshift
Array.prototype.unshift() - JavaScript | MDN
const arr = [1, 2]; arr.unshift(0); ... arr.unshift([-7, -6], [-5]); // the new array length is 8 // arr is [ [-7, -6], [-5], [-4, -3], -2, -1, 0, 1, 2 ] The unshift() method reads the length property of this....
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › shift
JavaScript Array shift() - Remove First Element | Vultr Docs
November 25, 2024 - The shift() method in JavaScript is a straightforward but powerful tool for manipulating arrays. It primarily focuses on removing the first element from an array and returning that removed element, altering the length of the array in the process.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Array methods
That’s natural, because delete obj.key removes a value by the key. It’s all it does. Fine for objects. But for arrays we usually want the rest of the elements to shift and occupy the freed place.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-shift-method
JavaScript Array shift() Method - GeeksforGeeks
September 18, 2024 - JS Tutorial · Web Tutorial · ... : 18 Sep, 2024 · The shift() method in JavaScript is used to remove the first element of an array, reducing the array's length by one....
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript array shift method
JavaScript Array Shift Method
September 1, 2008 - The JavaScript Array.shift() method is used to remove the first element from an array and returns the removed element. This method reduces the length of the original array by one. When we call this method on the empty array, it returns "undefined".
🌐
freeCodeCamp
forum.freecodecamp.org › guide
How to use JavaScript Array.prototype.shift() - JavaScript Shift Explained with Examples
June 23, 2019 - The JavaScript array method .shift() will remove the first element from an array and return that value. This will also change the length of the array Syntax var array = [1, 2, 3, 4]; array.shift(); Description .shift(…
🌐
CodingNomads
codingnomads.com › javascript-array-unshift-shift-pop-push
JavaScript Array Essentials: Using pop, push, shift, and unshift
The names "shift" and "unshift" are relatively unique to JavaScript, however, they do describe the actions being performed on the array - one "shifts" elements out of the array, while the other "unshifts" or pushes elements into the array from ...
🌐
Medium
medium.com › an-idea › javascript-arrays-push-pop-shift-unshift-adc8fb815fc0
JavaScript Arrays: push(), pop(), shift() & unshift() | by Amanda M Johnson | An Idea (by Ingenious Piece) | Medium
October 10, 2021 - JavaScript Arrays: push(), pop(), shift() & unshift() When working with arrays, it is important to understand the different types of methods and how they transform your data. push(), pop(), shift() …
🌐
Lucee Documentation
docs.lucee.org › reference › functions › arrayshift()
array.shift() :: Lucee Documentation
pops the first element from an array and shift the rest of the values to the left. In case the array is empty an exception is thrown, unless the second argument "defaultValue" is provided, in that case that value is returned.
🌐
Programiz
programiz.com › javascript › library › array › shift
JavaScript Array shift()
To remove the last element of an array, use the JavaScript Array pop() method. var languages = ["JavaScript", "Python", "Java", "C++", "Lua"]; var shifted = languages.shift(); console.log(languages); // [ 'Python', 'Java', 'C++', 'Lua' ] console.log(shifted); // JavaScript // shift returns any type of object var numbers = [ [1, 2, 3], [4, 5, 6], [-5, -4, -3], ];
🌐
Flexiple
flexiple.com › javascript › javascript-shift
Javascript Shift() - uses and limitations - Flexiple
March 11, 2022 - Learn about JavaScript's shift() method, which removes the first element from an array and returns it, altering the array's length and content.
🌐
Educative
educative.io › answers › what-is-the-arrayshift-method-in-javascript
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.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.shift()
JavaScript Array shift() Method
November 6, 2024 - The Array.prototype.shift() method removes the first element from an array and returns that element.