Add a new item to an array:
The result of fruits will be:
The push() method adds new items to the end of an array, and returns the new length.
Note: The new item(s) will be added at the end of the array.
Note: This method changes the length of the array.
Tip: To add items at the beginning of an array, use the unshift() method.
![]()
The push() method is supported in all major browsers.
| Parameter | Description |
|---|---|
| item1, item2, ..., itemX | Required. The item(s) to add to the array |
| Type | Description |
|---|---|
| Number | The new length of the array |
| JavaScript Version: | 1.2 |
|---|
Add more than one item:
The output of the code above will be:
JavaScript Array Object
Your message has been sent to W3Schools.