Chrome Extension

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

var items = ["Apple", "Banana", "Orange"];
items.unshift("Papaya", "Watermelon");

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.

Search history ×