方法一:使用"+"将两个字符串"相加"
示例:
var longString = "One piece " + "plus one more piece.";
//结果:longString值为:"One piece plus one more piece.";
方法二: 要将多个字符串累积为一个字符串,还可以使用"+="操作符:
示例:
var result = "";
result += "My name is Anders"
result += " and my age is 25";
//结果:result值为"My name is Anders and my age is 25"
方法三:方法concat()(),它完成与"+"相同的功能:
string.concat(value1, value2, ...)
示例:
var str4="字符串连接";
str4=str4.concat("use concat function connec string");
//结果:"字符串链接use concat function connec string"
最直接 简单的 'str1' + 'str2';
str += str1;
.
.
.