Chrome Extension

Add new item at first position of array using unshift() method Javascript

var items = ["Apple", "Banana", "Orange"];
items.unshift("Papaya", "Watermelon");
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now
["Papaya", "Watermelon", "Apple", "Banana", "Orange"]

If you want to add a new item to an array at its first position, you can use .unshift() method in javascript. This will insert the items to the very first position of the array. Items are passed as the parameters into unshift() method.

Was this helpful?
Open Code Manager We are hiring