9. 模板语法和分隔符

ES6 中有一种十分简洁的方法组装一堆字符串和变量。

  • ${ … } 用来渲染一个变量
  • ` 作为分隔符
  1. let user = 'Barret';
  2. console.log(`Hi ${user}!`); // Hi Barret!