Array.push() : Push : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Push »

 

Array.push()















Syntax array.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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Push