Adds one or more elements to the beginning of an array and returns the new length of the array.
Method of Array
Syntax
arrayName.unshift(element1,..., elementN )
Parameters
element1,...,element_N | The elements to add to the front of the array. |
Example
The following code displays the myFish array before and after adding elements to it.
This example produces the following results:
myFish before: ["angel", "clown"]
myFish after: ["drum", "lion", "angel", "clown"]
New length: 4