Return to Kroll Design home page

JavaScript Tutorials

 
« Return

concat method for arrays

The concat method joins multiple arrays into one new array.

Code:

<script type="text/javascript">
//<![CDATA[
array1 = new Array("triangle", "circle", "square"); array2 = new Array("rectangle", "pentagon", "hexagon"); shapes = array1.concat(array2); for (i=0; i<array1.length; i++) { document.write("array1[", i, "] : ", array1[i], "<br>"); } document.write("<br>"); for (i=0; i<array2.length; i++) { document.write("array2[", i, "] : ", array2[i], "<br>"); } document.write("<br>"); for (i=0; i<shapes.length; i++) { document.write("shapes[", i, "] : ", shapes[i], "<br>"); } //]]> </script>

Output:



 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM