JavaScript Array push() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

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().

Remember
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.

JavaScript
array.push(...items)
CallWhat 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
JavaScript
array.push(...items)

Parameters

ParameterDescription
ArrayRequired. Target to grow
...itemsOptional. Values to append (zero or more)

Return Value

Return ValueDescription
*New length (number)

JavaScript Examples

Example 1 — Add Elements to the End

Append 4 and 5 onto a number list.

JavaScript
const numbers = [1, 2, 3];

numbers.push(4, 5);

console.log(numbers);
// [1, 2, 3, 4, 5]
Try It Yourself

How It Works

  1. Start with three numbers. Length is 3.
  2. Pass two arguments. push(4, 5) appends both in order.
  3. Array grows. New slots are at the end.
  4. 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.

JavaScript
const fruits = ["apple", "orange"];

const newLength = fruits.push("banana", "grape");

console.log(newLength);
// 4
console.log(fruits);
// ["apple", "orange", "banana", "grape"]
Try It Yourself

How It Works

  1. Start with two fruits. Length is 2.
  2. Push two more. Length becomes 4.
  3. Return value is 4. Stored in newLength.
  4. 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.

JavaScript
const fruits = ["apple", "orange"];
const vegetables = ["carrot", "broccoli"];

fruits.push(...vegetables);

console.log(fruits);
// ["apple", "orange", "carrot", "broccoli"]
Try It Yourself

How It Works

  1. Spread expands the source. ...vegetables becomes separate arguments.
  2. Same as two pushes. Equivalent to push("carrot", "broccoli").
  3. fruits grows. Original array is mutated.
  4. Want a new array? Use concat or [...fruits, ...vegetables] instead.

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.

100% Universal support
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

push() adds one or more elements to the end of an array, increases length, and returns the new length.
Yes. push() changes the array in place by appending elements at the end.
The new length of the array (a number), not the array itself. You cannot chain array methods on the return value of push().
push() adds to the end; pop() removes from the end. Together they implement a LIFO stack.
push() mutates and returns a length. concat() returns a new array and leaves the original unchanged.
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

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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