Add New Item to Beginning of Array in JavaScript

In this article, we are just going to look at an array function called unshift which adds an item to the beginning index of an array. Here is the syntax as follows:

This function accepts n number of arguments representing items to add at the beginning of an array.

Let’s see an example with single item to add:

Example with multiple items to add:

As simple as that is. Hope this article is helpful. If you are looking for more topics, visit this link and post what you want on this blog and leave your queries in the comment section.