Removes the first element from an array and returns that element. This method changes the length of the array.
Method of Array
Syntax
shift()
Parameters
None.
Example
The following code displays the myFish array before and after removing its first element. It also displays the removed element:
This example produces the following results:
myFish before: ["angel", "clown", "mandarin", "sturgeon"]
myFish after: ["clown", "mandarin", "sturgeon"]
Removed this element: angel