JavaScript Array Object manipulation (Array object)
The push () method adds one or more elements to the end of the array and returns the new length.
Note: The new element is added at the end of the array.
Note: This method changes the length of the array.
tip: to add elements at the beginning of an array, use the Unshift () method. This method changes the length of the array!!!
The Pop () method deletes the last element of the array and returns the deleted element. This method changes the length of the array!!!
To remove the first element of an array, use the Shift () method. This method changes the length of the array!!!
Syntax: array. Push (item1, item2, ..., ItemX)
eg
var fruits = ["Banana", "Orange", "Apple", "Mango"];
Fruits.push ("Kiwi", "Lemon", "Pineapple");
Output:
Banana,orange,apple,mango,kiwi,lemon,pineapple
JavaScript push () method