JavaScript Array unshift

JavaScript Array unshift


JavaScript Array unshift()
In this Tutorial, we will learn about JavaScript Array unshift() method with the help of following below:
The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.
Syntax
array.unshift()
Example- Insert an element to the beginning of an array Fruits with the help of unshift() method:
Output
Example2- Insert two elements to the beginning of an array Fruits with the help of unshift() method:
Output