Array.prototype.unshift(...items) inserts one or more values at the start of an array, shifts existing indexes up, grows length, and returns the new length (not the array). It mutates in place — the pair of shift().
Remember
array.unshift(item1, item2, …)
adds to the start
returns new length (a number)
mutates the array
pair with shift() → queue at the front
vs push() → push adds at the end
Syntax
Call array.unshift. Start with this line.
JavaScript
array.unshift(...items)
Call
What it does
array.unshift(...items)
Primary signature.
array.unshift(...)
Call with the arguments your case needs.
Built into JavaScript. Call unshift(...) on an array instance — no import required.
Array.prototype.unshift() is one of the oldest array methods, available since JavaScript 1.2 / ES3.
✓ Baseline · ES3
Array.prototype.unshift()
Supported in every browser ever shipped with JavaScript arrays, including Internet Explorer, and all Node.js versions.
100%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Array.unshift()Universal
Bottom line: Safe to use in any environment. No polyfill needed.
Frequently Asked Questions
unshift() adds one or more elements to the beginning of an array, shifts existing elements to higher indexes, increases length, and returns the new length.
Yes. unshift() changes the original array in place. Use spread ([...items, ...arr]) or concat when you need a new array without mutating the original.
The new length of the array after insertion—not the array itself. This matches push() behavior.
unshift() adds at index 0 (the start). push() adds at the end. unshift() is slower on large arrays because every existing element moves one index right.
unshift() adds to the front. shift() removes from the front. They are opposites at the start of the array.
unshift() has been available since JavaScript 1.2 / ES3 and works in every browser and Node.js environment.