July 1998
Intermediate to advanced
1456 pages
65h 5m
English
?: — NN 2 IE J1 ECMA 1
The conditional operator. This operator provides a shortcut syntax to
an if/else control structure. There are three
components to the deployment of this operator: a condition and two
statements. If the condition evaluates to true, the first of the
statements is executed; if the condition evaluates to false, the
second statement is evaluated. The syntax is as follows:
condition ? statement1 : statement2This operator is a shortcut in appearance only. It invokes the same
internal processing as an if...else construction.
var newColor = (temp > 100) ? "red" : "blue"
Read now
Unlock full access