Array.push() : Push « Array « JavaScript Tutorial






Syntaxarray.push(arg1,...argN)


The push() method "pushes" the elements to the end of the array in the order they were listed.

arg1,...argN are elements to be pushed to the end of the array

It returns the last element added to the end of the array, which is also the last argument in the parameter list.

The following example uses the push() Method to Add Elements to the End of an Array.

<html>
    <script language="JavaScript">
    <!--
    pileOfPapers = new Array("A","B");
    currentPaper = pileOfPapers.push("C","D");
    document.write(pileOfPapers.join(',')," are in the pile.");
    -->
    </script>
</html>








11.22.Push
11.22.1.Array.push()
11.22.2.Separating an Array
11.22.3.Using push method from zArray Library