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
Prev | Home | Next |
Conditional comment | Up | Conditional operator |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |