[Contents] [Previous] [Next] [Index]

if...else

Executes a set of statements if a specified condition is true. If the condition is false, another set of statements can be executed.

Implemented in

Navigator 2.0, LiveWire 1.0

Syntax

if (condition) {
   statements1}
[else {
   statements2}]

Arguments

condition
Can be any JavaScript expression that evaluates to true or false. Parentheses are required around the condition. If condition evaluates to true, the statements in statements1 are executed.

statements1 statements2
Can be any JavaScript statements, including further nested if statements. Multiple statements must be enclosed in braces.

Examples

if (cipher_char == from_char) {
   result = result + to_char
   x++}
else
   result = result + clear_char


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 12:29:59


Copyright � 1997 Netscape Communications Corporation