Export (0) Print
Expand All
Expand Minimize

shift Method (Windows Scripting - JScript)

Updated: March 2009

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

Date

History

Reason

March 2009

Added example.

Information enhancement.

Community Additions

ADD
Show:
© 2014 Microsoft