Unshift method to add element to an arrayWe have seen how to add element at the end of an array by using push() method. Same way we can add elements at the beginning of an array by using unshift() method. Here is the general syntax for using unshift() method.
Here scripts is our array object and we are adding two new elements VBScript and Perl at the beginning of this array by using unshift() method.
Here is the complete code for unshift()
The above code will add VBScript and Perl at the end of the array and display the full list.