join Function:
Joins all elements of an array into a string.
Syntax:
join(separator);
Example in HEAD section:
<html> <head> <script language="javacsript"> num=new Array("One""two","Three","our"); var str; str=num.join(); document.write(str + "<br>"); str=num.join(" , "); document.write(str + "<br>"); str=num.join(" + "); document.write(str + "<br>"); </script> </head> </html> |
Example in BODY section:
<html> <head> <script language="javacsript"> </head> <body> num=new Array("One""two","Three","our"); var str; str=num.join(); document.write(str + "<br>"); str=num.join(" , "); document.write(str + "<br>"); str=num.join(" + "); document.write(str + "<br>"); </script> </body> </html> |
OUTPUT
One,two,Three,Four
One , two , Three , Four
One + two + Three + Four