Home >Web Front-end >JS Tutorial >Introduction to the use of javascript(js) join function_javascript skills
The array object itself provides many methods for operating on the object itself, and join is one of the methods.
Format:
objArray.join(seperator)
Usage:
Use the character specified by seperator as the separator to convert the array into a string. When seperator is a comma, its effect is the same as Same as toString().
Example:
For example, we have a string "a", "b", "c" and we want to output it in the format of a, b, c, then we can do this:
var a = ["a","b","c"];
document.write(a);
If you use join, it must be like this:
var a = ["a"," b","c"].join(",");
document.write(a);
If you say you want to output abc directly instead of a, b, c, then use join Couldn't be more appropriate.
var a = ["a","b","c"].join("");
document.write(a);
Demo: