JavaScript (JS) Join function Using method introduction _javascript Skill

Source: Internet
Author: User
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]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.