- The new items are added to the end of the variable.
Tip: while unshift() method has a similar function, it adds items to the beginning of the array.
Syntax and Usage
The syntax rules for this method are very simple. See it for yourself:
array.push(item1, item2, ...)
The following example illustrates how a new element (
Rover) is to be added to the
cars array. Analyze the full code by clicking the Try it Live button:
var cars = ["Audi", "BWM", "Mercedes", "Porsche"]; cars.push("Rover");
Latest Coupon Found:
TOP-RATED CODING COURSES
Learn the skills of tomorrow
The best time to learn programming is now - follow this link to access 100+ coding courses and enjoy learning at a very low cost!