+ 2
what's the output?
alert(false?true:false); I don't see why the output would be "false"?
5 ответов
+ 5
ternary operator means this:
condition ? true : false
if condition is true, then choose the option after the ? symbol. if condition is false, then choose the option after the : symbol
condition is false, so it will choose the value after the : symbol which is "false"
+ 6
U might wanna look up javascript conditional ternary operator to understand what's going on
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
+ 4
If false then true else false
Since false is not true you get false
+ 1
The output is false because the expression false? equals false. If it was true?, you would get true.
0
The syntax is
Condition given ? True : false
It's similar to if else - here option just after ? Gets printed if the condition is true and similarly the option just after : gets printed if the condition is false.