Array shift()
syntax: |
array.shift() |
return: |
value - the first element of the current Array object. The element is removed from the array after being returned.
|
description: |
If the length of the current Array object is 0, then undefined is returned. Otherwise, the first element is returned. This element is deleted from the array, and any remaining elements are shifted down to fill the gap that was created. The shift() method works on the beginning of an array, whereas, the Array pop() method works on the end.
|
see: |
|
example: |
//The following code:
var array = new Array( 1, 2, 3 ); Screen.writeln( array.shift() ); Screen.writeln( array );
// First prints out "1", // and then the contents of the array, // which converts to the string "2,3". |