js中多行字符串 連接字符串
1.通過+進行字符串的拼接
let str = "Hello";
str = str + "World";
console.log(str); // HelloWorld
2.使用concat()進行字符串拼接
let str1 = "Hello";
str2 = "World";
console.log(str1.concat(str2)); // HelloWorld
3.以數組作為中介用join連接字符串
let arr = new Array();
arr.push("Hello");
arr.push("World");
let str = arr.join("");
console.log(str); // HelloWorld
4.ES6字符串拼接方法 模板字符串
let name="amber";
city ="hangzhou";
message = `${name} is come from ${city} !`;
console.log(message); // amber is come from hangzhou !
ps:在模板字符串中設置幾個空格就會顯示幾個空格。