我是靠谱客的博主 爱撒娇星星,这篇文章主要介绍JavaScript中使用concat()方法拼接字符串的教程,现在分享给大家,希望可以做个参考。

 这种方法将两个或多个字符串,并返回一个新的单字符串。
语法

string.concat(string2, string3[, ..., stringN]);

下面是参数的详细信息:

  •     string2...stringN : 这些是要连接字符串。

返回值:

返回一个连接字符串。
例子:

<html>
<head>
<title>JavaScript String concat() Method</title>
</head>
<body>
<script type="text/javascript">
var str1 = new String( "This is string one" );
var str2 = new String( "This is string two" );
var str3 = str1.concat( str2 );

document.write("Concatenated String :" + str3); 
</script>
</body>
</html>

这将产生以下结果:

Concatenated String :This is string oneThis is string two.

最后

以上就是爱撒娇星星最近收集整理的关于JavaScript中使用concat()方法拼接字符串的教程的全部内容,更多相关JavaScript中使用concat()方法拼接字符串内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(301)

评论列表共有 0 条评论

立即
投稿
返回
顶部