Home » JavaScript Array push() Method

JavaScript Array push() Method

by Online Tutorials Library

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.

Syntax

The push() method is represented by the following syntax:

Parameter

element1,element2….elementn – The elements to be added.

Return

The original array with added elements.

JavaScript Array push() method example

Let’s see some examples of push() method

Example 1

Here, we will add an element in the given array.

Test it Now

Output:

AngularJS,Node.js,JQuery  

Example 2

Let’s see an example to add more than one elements in the given array.

Test it Now

Output:

Length before invoking push(): 2  Length after invoking push(): 4  Update array: AngularJS,Node.js,JQuery,Bootstrap  

Next TopicJavaScript Array

You may also like