4. The unshift() Method


          Another way to add an element to an array is using the unshift() method. Unlike the push() method, this method will add an item at the beginning of an array.

 For example,

 var myArray = ["Kate", "Sun"];

myArray.unshift("Juliet"); //Adds "Juliet" at the beginning of the array

myArray.unshift("Libby", "Shannon"); //Adds "Libby" and "Shannon" at the beginning of the array

console.log(myArray);

 

          Printing the array of the example above, the result would be ["Libby", "Shannon", "Juliet", "Kate", "Sun"].