arr.unshift() is used to add one or more elements to the beginning of the given array. This function increases the length of the existing array by the number of elements added to the array. The syntax of the function is as follows:
arr.unshift(element1[, ...[, elementN]])
The number of arguments to this function is same as the number of elements to be added at the beginning of the array.
This function returns the new length of the array after inserting the arguments at the beginning of the array.
Example for the above function is provided below:
var arr = [23,76,19,94]; print(arr.unshift(28,65)); print(arr);
In this example the function unshift() adds 28 and 65 to the front of the array.
Code for the above function is provided below: