k01ken’s b10g

He110 W0r1d!

ES2018(ES9)に関する私的メモ

テンプレートリテラル

テンプレートリテラルはダブルクォートやシングルクォートではなくて、`~`(バックティック)で文字列を囲みます。

console.log(`${3 * 3 * 3}`); // 27

let name = "Taro";
console.log(`Hello ${name}!`); // Hello Taro!

■参考リンク
テンプレートリテラル (テンプレート文字列)

スプレッド構文

...変数名』を指定して、リストなどに組み入れることで、中身をそのまま展開できます。

const arr = ['apple', 'orange', 'grape'];
const arr2 = [...arr, 'banana', 'strawberry']; // Array(5) [ "apple", "orange", "grape", "banana", "strawberry" ]

■参考リンク
スプレッド構文