Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Array.prototype.push: appending at the end

push appends any number of values from the current length and returns the receiver’s new length.

Version: ECMAScript 2026 draft; example target: Node.js 24.22.2

Syntax

array.push(...items)

array.push(...items) reads length, writes successive items starting at that index, sets the new length, and returns it as a number. Arguments are stored without flattening; a call with no arguments still returns the current length. The method mutates its receiver and is generic for mutable array-like objects.

A null or undefined receiver throws TypeError. If length plus the argument count would exceed the maximum safe length 2^53 - 1, the algorithm throws TypeError. A real Array additionally has the 2^32 - 1 length limit. A non-writable index, read-only length, or Proxy trap can throw, and earlier writes need not be rolled back. The example shows an array, an array-like object, and failure on a non-extensible array.

Examples

const values = ["a"];
console.log(values.push("b", "c"), values.join(","));
const record = { 0: "x", length: 1 };
console.log(Array.prototype.push.call(record, "y", "z"), record.length, record[1] + record[2]);
const fixed = Object.preventExtensions(["x"]);
try { fixed.push("y"); } catch (error) {
  console.log(error.name, fixed.length);
}

Result

3 a,b,c
3 3 yz
TypeError 1

Sources