Conditional expression (Definition)

Conditionally execute one code branch or another.


ECMAScript edition - 2

Conditional expressions test a logical expression and perform one of two possible alternative code blocks.

The grammar for a conditional expression in ECMA-compliant JavaScript implementation is slightly different to that you may have seen before in Java and C language. Java and C set restrictions on the kind of expression you can put into the second code block, whereas JavaScript does not. This is a subtle distinction and is intended to simplify the use of this expression and avoid the use of a comma operator.

See also:Conditionally execute (?:), Expression


ECMA 262 edition 2 - section - 11.12

ECMA 262 edition 3 - section - 11.12

Wrox Instant JavaScript - page - 18