Return to Kroll Design home page

JavaScript Tutorials

« Return

toString method for arrays

The toString method fuses the elements of an array into one character string, with a comma delimiter to separate the former elements.

Using the join method without specifying a delimiter will give you the same result.


<script type="text/javascript">
myArray = new Array("a", "b", "c", "d", "e", "f"); for (i=0; i<myArray.length; i++) { document.write("myArray[", i, "] : ", myArray[i], "<br>"); } document.write("<br>myArray.toString() : ", myArray.toString(), "<br>"); document.write("<br>myArray.join() : ", myArray.join(), "<br>"); //]]> </script>


« Return

©2012 Kroll Design    781.910.3694
Last modified: 12/31/1969 7:00 PM