You can actually accomplish this using the .concat method if you call it on an array of elements you want to put at the front of the new array.

Working Example:

var a = [1, 2, 3];
var b = [0].concat(a);
console.log(a);
console.log(b);

Alternately, in ECMAScript 6 you can use the spread operator.

Working Example (requires modern browser):

var a = [1, 2, 3]
var b = [0, ...a];
console.log(a);
console.log(b);

Answer from Alexander O'Mara on Stack Overflow
🌐
Meticulous
meticulous.ai › blog › javascript-unshift-complete-guide
JavaScript Unshift | In-Depth Guide & Tutorial
The original array arr was mutated ... the .unshift call. Mutation is something to be careful about because it is a common cause of unexpected issues which can be tricky to debug. To drive this point home, the paradigm of functional programming has an explicit goal of avoiding mutation and having pure functions (functions without mutation or ...
🌐
Doesitmutate
doesitmutate.xyz
Does it mutate?
const array1 = [1, 2, 3]; console.log(array1.unshift(4, 5)); // Expected output: 5 console.log(array1); // Expected output: Array [4, 5, 1, 2, 3]
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › unshift
Array.prototype.unshift() - JavaScript | MDN
The unshift() method reads the length property of this. It shifts all indices in the range 0 to length - 1 right by the number of arguments (incrementing their values by this number). Then, it sets each index starting at 0 with the arguments passed to unshift().
🌐
Medium
vtechguys.medium.com › javascript-array-methods-mutating-vs-non-mutating-8606d9b78c77
Javascript: Array Methods | Mutating vs Non-Mutating | by Aniket Jha | Medium
May 24, 2020 - array.push() adds an item to the end and array.unshift() adds an item to the front of the array. There are two ways to do so array.concat() and …array spread operator. // Note use `const` to indicate that this will not be mutated const array1 = [1, 2, 3, 4, 5]; const array2 = array.concat(6); // [1, 2, 3, 4, 5, 6];const array3 = [...array1, 6]; // [1, 2, 3, 4, 5, 6]; const array4 = [10, ...array1]; // [10, 1, 2, 3, 4, 5];
🌐
W3Schools
w3schools.com › jsref › jsref_unshift.asp
JavaScript Array unshift() Method
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion ... const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.unshift("Lemon","Pineapple"); Try it Yourself »
Find elsewhere
🌐
Coding Defined
codingdefined.com › 2017 › 04 › mutating-and-non-mutating-javascript.html
Mutating and Non-Mutating JavaScript Array Functions - Coding Defined
Non-Mutating Methods in JavaScript are array.concat(), array.includes(), array.indexOf, array.join(), array.lastIndexOf, array.slice(), array.toString() and array.toLocaleString(). Adding new item to the Array - In JavaScript you can use ...
🌐
DEV Community
dev.to › liaowow › to-mutate-or-not-to-mutate-javascript-array-methods-cheat-sheet-5092
To Mutate, Or Not To Mutate? JavaScript Array Methods Cheat Sheet - DEV Community
February 22, 2020 - It is here to help us remember ... (popping) the last item (poop). The .unshift() method works similarly to .push(), except that it adds a new item to the beginning of the array....
🌐
Lorenstewart
lorenstewart.me › 2017 › 01 › 22 › javascript-array-methods-mutating-vs-non-mutating
Lorenstewart
May 21, 2018 - // since the array will be mutated, // use 'let' rather than 'const' let mutatingAdd = ['a', 'b', 'c', 'd', 'e']; mutatingAdd.push('f'); // ['a', 'b', 'c', 'd', 'e', 'f'] mutatingAdd.unshift('z'); // ['z', 'a', 'b', 'c', 'd', 'e' 'f'] ... There are two ways to add new items to an array without mutating the original array.
🌐
Educative
educative.io › home › courses › simplifying javascript: a handy guide for software engineers › tip 8: avoid push mutations with the spread operator
Avoid Push Mutations Using the JavaScript Spread Operator
Node.js · // Add to beginning. const titles = ['Moby Dick', 'White Teeth']; titles.unshift('The Conscious Mind'); console.log("Titles after using unshift: " + titles) const moreTitles = ['Moby Dick', 'White Teeth']; const evenMoreTitles = ['The Conscious Mind', ...moreTitles]; console.log("Adding titles using spread operator: " + evenMoreTitles); // Copy ·
🌐
Doesitmutate
doesitmutate.xyz › unshift
unshift
const array1 = [1, 2, 3]; console.log(array1.unshift(4, 5)); // Expected output: 5 console.log(array1); // Expected output: Array [4, 5, 1, 2, 3]
🌐
Cheesecake Labs
cheesecakelabs.com › home › blog › engineering › how to avoid array mutation
How to Avoid Array Mutation
July 1, 2022 - To show an example of mutating, we’ll use the following array: const heroesMutate = ['Spider-man', 'Thor', 'Hulk', 'Iron Man']; console.log(heroesMutate); // => ["Spider-man", "Thor", "Hulk", "Iron Man"] ... heroesMutate.push('Captain Marvel'); console.log(heroesMutate); // => ["Spider-man", "Thor", "Hulk", "Iron Man", "Captain Marvel"] heroesMutate.unshift('Deadpool'); console.log(heroesMutate); // => ["Deadpool", "Spider-man", "Thor", "Hulk", "Iron Man", "Captain Marvel"] heroesMutate.splice(2, 0, 'Black Panther'); console.log(heroesMutate); // => ["Deadpool", "Spider-man", "Black Panther", "Thor", "Hulk", "Iron Man", "Captain Marvel"]
🌐
Artem Sapegin
blog.sapegin.me › all › avoid-mutation
Washing your code: avoid mutation by Artem Sapegin
Info The Object.assign() method was introduced in ECMAScript 2015. Before that, we didn’t even try to avoid mutation — it was too painful. Info Redux has a great page on immutable update patterns: it describes patterns for updating arrays and objects without mutation, and it’s useful even if we don’t use Redux.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-perform-unshift-operation-without-using-unshift-method-in-javascript
How to perform unshift operation without using unshift() method ...
August 5, 2025 - Performing an unshift operation in JavaScript without unshift() involves using array concatenation or the ES6 spread operator.
🌐
React
react.dev › learn › updating-arrays-in-state
Updating Arrays in State – React
In this way, spread can do the job of both push() by adding to the end of an array and unshift() by adding to the beginning of an array.
🌐
Medium
medium.com › @fknussel › arrays-objects-and-mutations-6b23348b54aa
Arrays, Objects and Mutations. This is a cross post, to check the… | by fedknu.com | Medium
August 22, 2023 - const numbers = [2, 3];numbers.unshift(1); // results in numbers being [1, 2, 3] In these two examples we are mutating or changing the original array. Remember, the goal is to keep the source array untouched. Let’s go through some alternatives to adding new elements to an array without altering the source.