Javascript Shift array method

Shift

Removes the first element from an array and returns that element. This method changes the length of the array.

Syntax

array.shift()

Example

// assumes a println function is defined
var myFish = [“angel”, “clown”, “mandarin”, “surgeon”];
println(“myFish before: ” + myFish);
var shifted = myFish.shift();
println(“myFish after: ” + myFish);
println(“Removed this element: ” + shifted);

Output

myFish before: angel,clown,mandarin,surgeon
myFish after: clown,mandarin,surgeon
Removed this element: angel
DOWNLOAD SOLUTION HERE