Control Structures
if
if (x == 1) {
// x equals 1} else if(x == 2) {
// x equals 2} else {
// other if(y == 1) z = 2;}
switch
switch(x){
case 1: // x==1
case 2: // x==2break;default: // None of the case labels match
}
loop
while(x == 1){
// Continues executing if x equals 1.}
do{// Continues executing if x equals 1.}while(x == 1);
for(var i = 0 /*initial expression*/; i < 10 /* condition */; i++ /* final expression */){// loop if(i == 4) continue; if(i == 9) break;}
for(var z /* temporary variable */ in ary /* array,object */){
}
Exception
try{
if(i == 0) throw new Error("0 was specified."); // Occurs exception}catch(e /* The variable which stored the exception */){
// The process at the time of exception occurred.}finally{
// Final cleanup}