Return to Kroll Web Design home page

JavaScript Tutorials

« Return

join method for arrays

The join method fuses the elements of an array into one character string, with the specified delimiter character to separate elements.
If you specify no delimiter character, a comma is used.
If you want no delimiter to show, specify a delimiter of double quote: "".

Code:

<script type="text/javascript">
//<![CDATA[
array1 = new Array("G", "l", "o", "r", "i", "a"); joinedString1 = array1.join(); document.write(joinedString1, "<br>"); joinedString2 = array1.join("-"); document.write(joinedString2, "<br>"); joinedString3 = array1.join(""); document.write(joinedString3, "<br>"); //]]> </script>

Output:




©2010 Kroll Web Design    davidarthurkroll@verizon.net    781.910.3694