The array object itself provides many methods for manipulating the object itself, and join is one of the methods.
Format:
Objarray.join (Seperator)
Use:
Converts an array to a string, using the character specified by Seperator, and the same function as ToString () when Seperator is a comma.
Example:
For example, we have a string "a", "B", "C" we want to output to a format such as A,b,c, then we can:
var a = ["A", "B", "C"];
document.write (a);
If you use join, it must be this way:
var a = ["A", "B", "C"].join (",");
document.write (a);
If you say you want to output ABC directly without outputting the a,b,c, then it is appropriate to use a join.
var a = ["A", "B", "C"].join ("");
document.write (a);
Demonstrate:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" > <ptml> <pead> ; <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <title>js join function </title> <script language=" JavaScript "type=" text/j Avascript "> var a = [" A "," B "," C "].join (" "); document.write (a); </script> </pead> <body> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]