The simple conditional operator has the form
x ? y : zIt yields y if x is 1 (true) and z if x is 0 (false). If x is not a boolean value, it yields undefined.
The complex conditionals are ``case'' and ``switch''. The expression
case{ c1 : e1; c2 : e2; ... cn : en; [default : ed;] }is equivalent to
c1 ? e1 : c2 ? e2 : ... cn ? en : edif there is a default case, and otherwise
c1 ? e1 : c2 ? e2 : ... cn ? en : undefinedThat is, if all the conditions c1...cn are false, and there is no default case, then the case expression is undefined.
The expression
switch(x){ v1 : e1; v2 : e2; ... vn : en; [default : ed;] }is equivalent to
(x in v1) ? e1 : (x in v2) ? e2 : ... (x in vn) ? en : edif there is a default case, and otherwise
(x in v1) ? e1 : (x in v2) ? e2 : ... (x in vn) ? en : undefined
That is, the switch expression finds the first set v that contains the value x, and returns the corresponding e. The v can also be single values - these are treated as the set containing only the given value.