How to add new elements into the Beginning of the array and shift the index of the subsequent element to the higher value ?
Method: unshift() :
This function add new elements into the Beginning of the array and shift the index of the subsequent elements to the higher value. It also returns the new length of the array.
var ele = stack.unshift(3);
In the above example, this method add new element to the beginning of the array and has displayed the result as"5".