Array.pop() : Pop « Array « JavaScript Tutorial






The pop() method "pops" elements off the end of the array.

The pop() method deletes the last element of the array and sets the array's length property to one less than its current value.

This last element is returned from the method.

The following example uses the pop() Method to Remove Elements from the End of an Array.

<html>
    <script language="JavaScript">
    <!--
    pileOfPapers = new Array("a","b","c");

    currentPaper = pileOfPapers.pop(); 

    document.write(currentPaper," was removed from the pile.");
    -->
    </script>
</html>








11.20.Pop
11.20.1.Array.pop()
11.20.2.Use Array.pop() to return last element in an array
11.20.3.Using pop method from zArray Library