Home JavaScript Array Methods push() JavaScript Array push() Method Definition Array.prototype.push(...items) appends one or more values to the end of an array, grows length, and returns the new length (not the array). It mutates in place — the pair of pop() .
array.push(item1, item2, …)
adds to the end
returns new length (a number)
mutates the array
push(...otherArray) → merge in place
pair with pop() → LIFO stack Syntax Call array.push. Start with this line.
Call What it does array.push(...items)Primary signature. array.push(...)Call with the arguments your case needs.
Built into JavaScript. Call push(...) on an array instance — no import required.
Library declarations Parameters Parameter Description Array Required. Target to grow ...items Optional. Values to append (zero or more)
Return Value Return Value Description * New length (number)
JavaScript Examples 1. Add elements 2. Return length 3. Merge with spread Example 1 — Add Elements to the End Append 4 and 5 onto a number list.
const numbers = [1, 2, 3];
numbers.push(4, 5);
console.log(numbers);
// [1, 2, 3, 4, 5] How It Works Start with three numbers. Length is 3.Pass two arguments. push(4, 5) appends both in order.Array grows. New slots are at the end.Same array object. numbers was mutated — no new array created.Example 2 — push() Returns the New Length Capture the return value — it is a number, not the array.
const fruits = ["apple", "orange"];
const newLength = fruits.push("banana", "grape");
console.log(newLength);
// 4
console.log(fruits);
// ["apple", "orange", "banana", "grape"] 4
["apple","orange","banana","grape"] How It Works Start with two fruits. Length is 2.Push two more. Length becomes 4.Return value is 4. Stored in newLength.Do not chain. fruits.push("x").map(...) fails because 4 has no map.Example 3 — Merge Another Array with Spread Append every item from a second array in one call.
const fruits = ["apple", "orange"];
const vegetables = ["carrot", "broccoli"];
fruits.push(...vegetables);
console.log(fruits);
// ["apple", "orange", "carrot", "broccoli"] ["apple","orange","carrot","broccoli"] How It Works Spread expands the source. ...vegetables becomes separate arguments.Same as two pushes. Equivalent to push("carrot", "broccoli").fruits grows. Original array is mutated.Want a new array? Use concat or [...fruits, ...vegetables] instead.Compatibility
Browser & Runtime Support Array.prototype.push() is one of the oldest array methods, available since JavaScript 1.2 / ES3 .
✓ Baseline · ES3
Array.prototype.push() Supported in every browser ever shipped with JavaScript arrays, including Internet Explorer, and all Node.js versions.
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support Array.push() Universal
Bottom line: Safe to use in any environment. No polyfill needed.
Frequently Asked Questions What does Array.push() do? push() adds one or more elements to the end of an array, increases length, and returns the new length.
Does push() mutate the original array? Yes. push() changes the array in place by appending elements at the end.
What does push() return? The new length of the array (a number), not the array itself. You cannot chain array methods on the return value of push().
How is push() different from pop()? push() adds to the end; pop() removes from the end. Together they implement a LIFO stack.
How is push() different from concat()? push() mutates and returns a length. concat() returns a new array and leaves the original unchanged.
Which browsers support push()? push() has been available since JavaScript 1.2 / ES3. It works in every browser, including very old ones.
Next: reduce() Learn how to reduce an array to a single value with a callback.
reduce() tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
15 people found this page helpful
Helpful Share Copy link Suggestion