Javascript array push() an inbuilt function that adds a new element at the end of an array and returns the new length of an array. The push() method modifies the length of the Array or collection. Arrays are kind of list objects whose prototype has methods to perform the mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed.

We can add new items in the Array using the following approach.

  1. Javascript array push() method is used to add items at the end of an array.
  2. Javascript array unshift() method is used to add items at the beginning of an array.
  3. Javascript array splice()  method is used to add elements within the Array.

So, in this example, we will see how we can perform javascript add to  array operation.

Understanding Javascript Array push()

Javascript array push() is an inbuilt method that can be used to append a  number,  string,  object, Array, or any value to the Array. JavaScript arrays are used to store multiple values in a single variable. An array data structure can hold many values under a single name, and you can access those values by referring to the index number.

Let us see the syntax of the Javascript Array push() method.

#javascript #javascript array push #js

Javascript array push: How to Add Item in Javascript Array
1.50 GEEK