Compartir a través de


shift Method (Windows Scripting - JScript)

 

Removes the first element from an array and returns it.

Syntax

arrayObj.shift( )

Remarks

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

Requirements

Version 5.5

Applies To: Array Object (Windows Scripting - JScript)

Change History

Date

History

Reason

March 2009

Added example.

Information enhancement.

See Also

unshift Method (Windows Scripting - JScript)