最近の書き方
-
バッククォートで囲むと文字列の変数をうめこむことができる。改行をすることも可能。
This is ${name}
-
objectのキーの省略可
変数名とオブジェクトのキーが同じ場合は省力可能
const name = 'taro';
const obj = {name};
// {name : 'taro'} -
桁埋めはpadStart
-
ネストされた配列をフラットにする flat
-
オプショナルチェイニング(エラーにならず最後までみてくれる)
obj.device?.normal?.id
→undefined -
null undfinedだったら右を返す
null ?? 1
undefined ?? 1
→1
false ?? 1
→false
0 ?? 1
→0 -
全部置換する replaceAll