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.

Join our 2500+ fellow readers

Join our 2500+ fellow readers

Joining our mailing list will for sure keep you at the top of Web Development Ecosystem. Connect with us and also other fellow developers.

You have Successfully Subscribed!

Pin It on Pinterest

Share This