JavaScript Array Push() Method - W3Schools
Maybe your like
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 number | The 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 |
Tag » Add Element Array Js
-
How To Append Something To An Array? - Stack Overflow
-
How To Add To An Array With The Push, Unshift, And Concat Functions
-
totype.push() - JavaScript - MDN Web Docs
-
5 Way To Append Item To Array In JavaScript
-
How To Add Elements Into An Array In JavaScript - Linux Hint
-
How To Add New Elements At The Beginning Of An Array In JavaScript
-
JavaScript: How To Insert Elements Into A Specific Index Of An Array
-
Javascript Array Push: How To Add Element In Array - AppDividend
-
JavaScript Program To Add Element To Start Of An Array - Programiz
-
JavaScript Program To Insert Item In An Array - Programiz
-
Add An Element To An Array In JavaScript - Mastering JS
-
TypeScript - Array Push() - Tutorialspoint
-
Add Element To Array At Specific Index In JavaScript | Bobbyhadz
-
How To Insert An Element In A Specific Index In JavaScript Array
-
JavaScript Array Splice(): Delete, Insert, And Replace
-
How To Add Item To An Array At A Specific Index In JavaScript
-
Javascript Tutorial | Adding Elements To Array In JavaScript - Morioh
-
Add An Item To The Beginning Of An Array In JavaScript Or Node.js
-
How To Add Element To UseState Array In JavaScript - Simplernerd