《不成问题》入围东京电影节 殷桃:较真的演戏

Baseline Widely available
百度 那些所谓霍金的不靠谱言论,一大半是媒体胡编乱造的,霍金从来没有说过。

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

if ?? ??? ??? ?? ?? ???(statement)? ?????. ??? ??? ?? ? ?? ???? ?? ? ? ????.

??? ??

function testNum(a) {
  let result;
  if (a > 0) {
    result = "positive";
  } else {
    result = "NOT positive";
  }
  return result;
}

console.log(testNum(-5));
// Expected output: "NOT positive"

??

js
    if (condition)
       statement1
    [else
       statement2]
condition

? ?? ???? ???? ??????.

statement1

??? ??? ??? ?? ???? ????. ??? if??? ???? ?? ???? ? ? ????. ????? ??? ?? ({ ... })?? ?? ?? ??? ?? ???? ???? ? ??? ?????.

statement2

? ??? ??? ????? ?? ??? ?? ? ???? ?????. ?? ?? if?? ??? ??? ???? ? ? ????.

??

??? if...else ?? else if ?? ??? ?? ??? ? ??. JavaScript??? elseif (??? ??) ???? ???? ???.

js
    if (??1)
       ???1
    else if (??2)
       ???2
    else if (??3)
       ???3
    ...
    else
       ???N

?? ??? ?? ??, if?? ?? ???? ????? ?? ??? ?????.

js
    if (??1)
       ???1
    else
       if (??2)
          ???2
       else
          if (??3)
    ...

??? ??? ???? ????? ?????, ? ????? ????? ?? ??? ({ ... }) ????? ????. ?????, ????? ?? ???? ?? ?? ?????. ?? ??? if ?? ???? ?? ????? ???? ?? ????.

js
if (??) {
  ????1;
} else {
  ????2;
}

?? ??? ?? true (?) ? false (??) ? ??? ??? truthiness (??? ??? ?) ? falsiness (???? ??? ?)?? ???? ???. false, undefined, null, 0, NaN, ?? ? ??? ("") ? ?? ?? ?, ??? false ?? ??? ??? ???? ?? ??? ???? ??? ? truthy ? ????. ?:

js
var b = new Boolean(false);
if (b) // ? ??? ??? ??? ? (truthy) ??.

??

if...else ????

js
if (cipher_char === from_char) {
  result = result + to_char;
  x++;
} else {
  result = result + clear_char;
}

else if ????

JavaScript?? elseif ??? ??. ???, else if ? ??? ? ??.

js
if (x > 5) {
} else if (x > 50) {
} else {
}

???? ?? ????

???? ???? ???? ?? ?? ????. ????, ??? ?? ?? ?? ????? ?????? ??? ? ?? ?????. ????, ????? ???? ???:

js
if (x = y) {
  /* do the right thing */
}

??? ???? ?? ??? ??? ??, ???? ??? ? ??? ? ??? ?? ??? ??? ???. ????:

js
if ((x = y)) {
  /* do the right thing */
}

???

Specification
ECMAScript? 2026 Language?Specification
# sec-if-statement

???? ???

?? ??