當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
string中concat_JavaScript中带示例的String concat()方法
生活随笔
收集整理的這篇文章主要介紹了
string中concat_JavaScript中带示例的String concat()方法
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
string中concat
字符串concat()方法 (String concat() Method)
concat() is a string method in JavaScript, it is used to concatenate (join) two or more strings and returns a new joined string.
concat()是JavaScript中的字符串方法,用于連接(聯(lián)接)兩個(gè)或多個(gè)字符串并返回新的聯(lián)接字符串。
Syntax:
句法:
String.concat(string1, string2, ...);It accepts string(s) and returns new string (which is joined string with the main string).
它接受字符串并返回新字符串(該字符串與主字符串連接在一起)。
Examples:
例子:
Input:str1 = "IncludeHelp"str2 = ".com"Function call: str1.contact(str2);Output:"IncludeHelp.com"Input:str1 = "Hello"str2 = " " //spacestr3 = "World!"Function call: str1.contact(str2, str2);Output:"Hello World!"Code:
碼:
<html> <head> <title>JavaScipt Example</title> </head> <body> <script> var str1 = "IncludeHelp";var str2 = ".com";document.write(str1.concat(str2) + "<br>");str1 = "Hello";str2 = " ";var str3 = "World!";document.write(str1.concat(str2, str3) + "<br>"); </script> </body> </html>Output
輸出量
IncludeHelp.com Hello World!翻譯自: https://www.includehelp.com/code-snippets/string-concat-method-with-example-in-javascript.aspx
string中concat
總結(jié)
以上是生活随笔為你收集整理的string中concat_JavaScript中带示例的String concat()方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android inflate,Andr
- 下一篇: Python | 在列表中指定索引处添加