JavaScript Array push()
Example
Add a new item to an array:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Adds "Kiwi"
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The push() method adds new items to the end of an array.
push() changes the length of the array and returns the new length.
Tip: To add items at the beginning of an array, use unshift().
Browser Support
push is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
array.push(item1, item2, ..., itemX)
Parameter Values
| Parameter | Description |
|---|---|
| item1, item2, ..., itemX | Required. The item(s) to add to the array |
Technical Details
| Return Value: | A Number, representing the new length of the array |
|---|---|
| JavaScript Version: | ECMAScript 1 |
More Examples
Example
Add more than one item:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi", "Lemon", "Pineapple");
Try it Yourself »
Example
push() returns the new length:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Returns 5
Try it Yourself »

