myArray.shift() in ECMAScript 262

Removes the first element of the array and returns it.

Return Type
Object

Description

Along with push(), this method allows arrays to be used as a 'queue' or 'FIFO' object. The following code illustrates the push() and shift() methods in use.
var thingsToDo=[];
thingsToDo.push('TheLaundry');
thingsToDo.push('TheDishes');
thingsToDo.push('PlayVideoGames');

thingsToDo.length == 3; //true
thingsToDo.toString() == "TheLaundry,TheDishes,PlayVideoGames"; //true

var firstThingToDo = thingsToDo.shift();
firstThingToDo == "TheLaundry"; //true

thingsToDo.length == 2; //true--shift() removed the item
thingsToDo.toString() == "TheDishes, PlayVideoGames"; //true