shift Method (Windows Scripting - JScript)

 

Removes the first element from an array and returns it.

arrayObj.shift( )

The required arrayObj reference is an Array 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);
while (ar.length > 0)
    {
    var i = ar.shift();
    document.write (i.toString() + " ");
    }

// Output: 10 11 12

Change History

Date

History

Reason

March 2009

Added example.

Information enhancement.

Show: