O'Reilly logo

Definitive VoiceXML™ by David Cuddihy, Adam Hocek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.4. Flow control

ECMAScript provides many flow control structures for controlling the execution of a program. These are summarized in Table A-4.

Table A-4. Summary of ECMAScript flow control structures
Flow control structureDescriptionExample
if...elseif...elseIf a given expression evaluates to true, an associated block of code will be executed, otherwise zero or more elseif conditions will be checked, and if none evaluates to true, a final else block of code will be executed (the else part is optional).
if(x < 3){
  x += 1;
} elseif(x < 1) {
  x += 2;
} else {
  x = 0;
}
forA loop with a built-in counter initialization, conditional check, and counter advance.
for(x = 0; x < 10; x++){
  y = y + x;
}
for...inA loop over each property of an object.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required