Array.shift() : Shift : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Shift »

 

Array.shift()









The shift() method deletes and returns the first element of the array.

Once deleted, all the remaining elements are shifted down one spot.

The first position is filled by the element that was previously in the second position.












<html>
    <script language="JavaScript">
    <!--
    lineOfPeople = new Array(""A","B","C");
    personToSeat = lineOfPeople.shift();

    document.write("Please seat ",personToSeat,"<br>");
    document.write("People waiting for a seat: ",lineOfPeople.join(', '));

    -->
    </script>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Shift