JavaScript Array Push() Method - W3Schools

JavaScript Array push() ❮ Previous JavaScript Array Reference Next

Examples

Add a new item to an array:

const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi"); Try it Yourself »

Add two new items to the array:

const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi", "Lemon"); Try it Yourself »

Description

The push() method adds new items to the end of an array.

The push() method changes the length of the array.

The push() method returns the new length.

See Also:

The Array pop() Method

The Array shift() Method

The Array unshift() Method

Syntax

array.push(item1, item2, ..., itemX)

Parameters

Parameters Description
item1item2..itemX The item(s) to add to the array. Minimum one item is required.

Return Value

Type Description
A numberThe new length of the array.

More Examples

Add 3 items to the array:

const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi", "Lemon", "Pineapple"); Try it Yourself »

push() returns the new length:

const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi"); Try it Yourself »

Array Tutorials:

Array Tutorial

Array Const

Basic Array Methods

Array Search Methods

Array Sort Methods

Array Iteration Methods

Browser Support

push is an ECMAScript1 (JavaScript 1997) feature.

It is supported in all browsers:

Chrome Edge Firefox Safari Opera
Previous JavaScript Array Reference Next +1 Sign in to track progress

Tag » Add Element Array Js