模版字符串 —— ``
会保留原样字符串格式,以及可以占位
/**
*
* 模版字符串 ``
* 会保留原样字符串格式,以及可以占位
*/
//ES5
//字符串没有格式,里面也不能写变量
// let author = "Stark";
// let str1 = "
// 你好,
// 世界
// ";
//ES6
let author = "Stark";
let str1 = `
静夜思
${author}
假如生活欺骗了你,
不要悲伤,
不要心急
忧郁的日子就会过去
`
console.log(str1);
// 1.
let name = "Stark";
let age = 38;
let score = 100;
console.log(`我的名字是${name},我的年龄是${age},我的战力是${score}`);
// 2.
function test(){
return 'hhh';
}
console.log(`我是钢铁侠,我会${test()}`);