Concat method Instance of a JavaScript string object (for connecting two or more strings) _ Basics

Source: Internet
Author: User
Tags first string

JavaScript Concat Method

The Concat method joins two or more strings with the following syntax:

Copy Code code as follows:

Str_object.concat (str1, str2, ...)

Str_object is the first string (object) that needs to be connected, str1 is the second string that needs to be connected, str2 is the third string that needs to be connected, and so on, at least one str1 is required.

Concat instance

Copy Code code as follows:

<script language= "JavaScript" >
var str = "www";
var str1 = ".";
var str2 = "jb51";
var str3 = ".";
var STR4 = "NET";
document.write (Str.concat (str1, str2, STR3, STR4));
</script>

Run the example and output:
Www.jb51.net
Tip: It is often easier to connect strings using the + operator, see also: JavaScript operator.

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.