LoginSignup
0
0

More than 5 years have passed since last update.

Basic Operators - Ternary Conditional Operator

Posted at

三項演算子 ternary conditional operator は、question ? answer1 : answer2 という構成で成り立っている。
動作としては、question の結果が真ならば answer1 の値を返す、偽ならば answer2 の値を返す。

例:

let contentHeight = 40
let hasHeader = true
let rowHeight = contentHeight + (hasHeader ? 50 : 20)
// rowHeight は 90 になる。
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