0
1

【JS】三項演算子で複数の処理を書く

Posted at

flgがtrueの時に処理Aと処理Bを実行したい場合

flg ? console.log(A)とconsole.log(B)を実行したい : null;

下記のようにカンマで区切ることで実行可能!

flg ? (console.log(A), console.log(B)) : null;
0
1
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
1