二元

if ( a == b) {
  alert(a)
}

// (a == b) && alert(a)
if ( a != b) {
  alert(a)
}

// (a == b) || alert(a)

三元

if (a == b) {
  alert(a);
} else {
  alert(b);
}

// (a == b) ? alert(a) : alert(b)
if (a > b) {
  alert(a);
} else if (b > c) {
  alert(b);
} else {
  alert(c):
}

// (a > b) ? alert(a) : (b > c) ? alert(b) : alert(c)

相关文章:

  • 2021-10-17
  • 2021-10-21
  • 2021-07-23
  • 2021-09-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案