2.1.3 Template Literals
改變了以往字串的寫法,不用再用 +
來進行字串與變數的結合。
const name = 'Andy';
// ES5寫法
var str = 'Hello' + name + "!";
// ES6寫法
const str = `Hello ${name}!`;
Last updated
Was this helpful?
改變了以往字串的寫法,不用再用 +
來進行字串與變數的結合。
const name = 'Andy';
// ES5寫法
var str = 'Hello' + name + "!";
// ES6寫法
const str = `Hello ${name}!`;
Last updated
Was this helpful?