Push New Items in JavaScript Array, this is the most simple statement that can be achieved with a JavaScript array. This is also very useful in order to build Arrays on the fly.

Now let’s see a very basic example where we will be pushing a data point into an Array

Array of Number

Array of String

Now let us insert some JSON data into a JSON Array.

Push into JSON Array

Merging Arrays using Push using apply()

If the length of the Second Array is not too large then you can go ahead and use apply() method in order to merge two arrays.

You can find all these running together out here below. Have a look at the code for each.


Check out all the other posts on JavaScript Essentials to get a Grasp of these JavaScript Utilities.

 


Also published on Medium.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Pin It on Pinterest

Share This