JavaScript Array push() Method


The JavaScript array push() method adds one or more elements to the end of the given array. This method changes the length of the original array.

Javascript array push() method appends the given element(s) in the last of the array and returns the length of the new array.

Syntax

array.push(item1, item2, ..., itemX)

Parameters This method contains as many numbers of parameters as the number of elements to be inserted into the array.

Return value: This method returns the new length of the array after inserting the arguments into the array.

Example

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi", "Lemon", "Pineapple");

Example -