The array object itself provides many methods for operations on the object itself. join is one of the methods.
Format:
ObjArray. join (seperator)
Purpose:
Use the character specified by seperator as the separator to convert the array into a string. When seperator is a comma, it serves the same purpose as toString.
Example:
For example, if we have a string "a", "B", and "c", we want to output it in a, B, and c format, then we can:
Var a = ["a", "B", "c"];
Document. write ();
If join is used, it must be as follows:
Var a = ["a", "B", "c"]. join (",");
Document. write ();
If you say that you want to directly output abc without outputting a, B, and c, it is not appropriate to use join.
Var a = ["a", "B", "c"]. join ("");
Document. write ();
Demo:
<! 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> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]