SOURCE

//模板字符串
let fruit = '梨子';
let desert = '面包';

//这是一种写法
let breakfast = '今天早上早餐吃了' + desert + ',水果吃了' + fruit;
console.log(breakfast)
// 第二种 ,是反引号
let breakfast2 = kitchen `今天早上早餐吃了 ${desert},水果吃了${fruit} 1`;
console.log(breakfast2)

//带标签的模板字段串
function kitchen(strings, ...values) {
   console.log(strings);
  console.log(values); 
  let result = '';
  for (var i=0;i<values.length;i++) {
result += strings[i];
    result += values[i];
}
  result+=strings[strings.length-1];
  return result;
  
}

//判断一个字符串是否包含其他的字符串

let messsage = "今天天气好晴朗";
console.log(messsage.startsWith("今天"),messsage.endsWith('晴朗'),messsage.includes("天气"));















console 命令行工具 X clear

                    
>
console