JScript Language Elements

| Tutorial | Reference |

Controlling Program Flow

| Conditionals | Looping | Break and Continue |

Conditionals:
JScript supports "if" and "if...else" conditional execution statements. In these statements a condition is tested, and if the condition meets the test, some JScript code is executed. (In the if...else statement, different code is executed if the condition fails the test.) The simplest form of an if statement can be written entirely on one line, but multiline if and if...else statements are much more common.

Remember that the test for equality uses a pair of equal signs, not just a single equal sign.

EXAMPLES:
if (newShip) smash(champagne,bow);        
   // Presumes a "smash"function definition elsewhere

if (rind.color == "deep yellow " && rind.texture == "large and small wrinkles")  
  {
     document.write("Is it a Crenshaw melon?<br>");
  }

if (lbsWeight < 15)  
  {
     document.write("What a cute kitty!");
  }
else
     document.write("That's one honker cat you've got there!");



© 1996 by Microsoft Corporation.