Home >Web Front-end >JS Tutorial >Introduction to the use of javascript(js) join function_javascript skills

Introduction to the use of javascript(js) join function_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:07:491217browse

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:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn