Arrays have been a very useful data type in all the programming languages. They are usually used to describe a collection of elements, values or variables. A lot of us might have come across scenarios where we had to insert a new value into the javascript array. Let us take a look at how to append or add new values to an existing Array using  JavaScript.

Add new values to Array using Array.push()

You can add values to an existing array using Array.push() method available in JavaScript. The Array.push() method accepts comma separated values as parameters and appends the new values to the end of the Array.

The Array.push() method alters an Array by appending the value to it and returns the new length of the Array.

The syntax of Array.push() method is :

Let’s take a look at another example:

Please note that the array.push() method appends the values to the end of the array. If you would like to insert the values at the beginning of the array then please use array.unshift();

Hope you are clear about the usage of Array.push() method. Do let us know about your queries and also do not forget to Like and Share this page.