《不成问题》入围东京电影节 殷桃:较真的演戏
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.
??? ??
function testNum(a) {
let result;
if (a > 0) {
result = "positive";
} else {
result = "NOT positive";
}
return result;
}
console.log(testNum(-5));
// Expected output: "NOT positive"
??
if (condition)
statement1
[else
statement2]
condition
-
? ?? ???? ???? ??????.
statement1
-
??? ??? ??? ?? ???? ????. ??? if??? ???? ?? ???? ? ? ????. ????? ??? ?? ({ ... })?? ?? ?? ??? ?? ???? ???? ? ??? ?????.
statement2
-
? ??? ??? ????? ?? ??? ?? ? ???? ?????. ?? ?? if?? ??? ??? ???? ? ? ????.
??
??? if...else ?? else if ?? ??? ?? ??? ? ??. JavaScript??? elseif (??? ??) ???? ???? ???.
if (??1)
???1
else if (??2)
???2
else if (??3)
???3
...
else
???N
?? ??? ?? ??, if?? ?? ???? ????? ?? ??? ?????.
if (??1)
???1
else
if (??2)
???2
else
if (??3)
...
??? ??? ???? ????? ?????, ? ????? ????? ?? ??? ({ ... }) ????? ????. ?????, ????? ?? ???? ?? ?? ?????. ?? ??? if ?? ???? ?? ????? ???? ?? ????.
if (??) {
????1;
} else {
????2;
}
?? ??? ?? true (?) ? false (??) ? ??? ??? truthiness (??? ??? ?) ? falsiness (???? ??? ?)?? ???? ???. false, undefined, null, 0, NaN, ?? ? ??? ("") ? ?? ?? ?, ??? false ?? ??? ??? ???? ?? ??? ???? ??? ? truthy ? ????. ?:
var b = new Boolean(false);
if (b) // ? ??? ??? ??? ? (truthy) ??.
??
if...else
????
if (cipher_char === from_char) {
result = result + to_char;
x++;
} else {
result = result + clear_char;
}
else if
????
JavaScript?? elseif ??? ??. ???, else if ? ??? ? ??.
if (x > 5) {
} else if (x > 50) {
} else {
}
???? ?? ????
???? ???? ???? ?? ?? ????. ????, ??? ?? ?? ?? ????? ?????? ??? ? ?? ?????. ????, ????? ???? ???:
if (x = y) {
/* do the right thing */
}
??? ???? ?? ??? ??? ??, ???? ??? ? ??? ? ??? ?? ??? ??? ???. ????:
if ((x = y)) {
/* do the right thing */
}
???
Specification |
---|
ECMAScript? 2026 Language?Specification # sec-if-statement |