0
0

More than 1 year has passed since last update.

JSの最近の書き方

Last updated at Posted at 2022-11-05

最近の書き方

  • バッククォートで囲むと文字列の変数をうめこむことができる。改行をすることも可能。
    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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0