This documentation is archived and is not being maintained.

shift Method

Removes the first element from an array and returns that element.

function shift() : Object

The shift method removes the first element from an array and returns it.

The following example illustrates the use of the shift method.

var ar = new Array(10, 11, 12);

var s = "";
while (ar.length > 0)
   {
   var i = ar.shift();
   s += i.toString() + " ";
   }

print (s);
// Output: 10 11 12
Show: