JavaScript Reference :: Statements

    break
    Stops execution of the block and exits to the containing block.
    catch
    Catches thrown exceptions.
    continue
    Continues with the next step in the iteration.
    delete
    Deletes the item.
    do
    Executes a block until the specified expression evaluates to false. Note that the block will execute at least one time because the while statement is evaluated after the specified block is executed.
    var i = 0;
    do {
    	var oCar = Cars[i]
    	oCar.start();
    }
    while (i < Cars.length);
    								
    export
    Allows a signed script to provided objects to other script.
    for
    Creates a loop.
    for (var c = 0; c < Cars.length; c++) {
    	var oCar = Cars[c];
    	oCar.start();
    }
    								
    if...else
    Executes the specified block if the expression evaluates to true. When coding a conditional, you should always use { and } to identify the block.
    if (Cars.length > 0) {
    	StartCars();
    } else {
    	BuildCars();
    }
    								
    import
    Allows a script to import objects exported by a signed script. See export.
    new
    Creates a new object of the specified type, calling the prototype.
    var oCar = new Car("Mazda", "Protege");
    								
    return
    Passes control back from a function and optionally returns an object.
    switch
    Tests an expression against a number of specified cases and executes the specified block. If a block is not terminated by a break statement, processing will continue into the next block. You can also specify a default block to execute when all other cases are false.
    switch (Cars.length) {
    	case 0:
    		alert("Your garage is empty!");
    		break;
    	case 1:
    		alert("You have only one car in your garage.");
    		break;
    	default:
    		alert("You have "+Cars.length+" cars in your garage.");
    }
    								
    this
    A reference to the current object.
    throw
    Throws the specified error. Allows a greater degree of control with a try...catch block.
    try {
    	if (Car.crashed) {
    		throw {type: "Accident", auto: Car};
    	}
    } catch (er) {
    	if (er.type == "Accident") {
    		alert("Your car, a "+er.auto.maker+" "+er.auto.model+", was in an accident.");
    	}
    }
    								
    try...catch
    Attempts to execute a block and catches errors.
    try {
    	if (Car.crashed) {
    		throw {type: "Accident", auto: Car};
    	}
    } catch (er) {
    	if (er.type == "Accident") {
    		alert("Your car, a "+er.auto.maker+" "+er.auto.model+", was in an accident.");
    	}
    }
    								
    typeof
    Returns the type of the operand.
    • boolean
    • function
    • number
    • object
    • string
    • undefined
    if (typeof oCar != object) {
    	alert("Oops! We've had a severe error.");
    }
    								
    while
    Creates a loop that executes while the expression evaluates to true.
    var i = 0;
    while (i < Cars.length) {
    	var oCar = Cars[i];
    	oCar.start();
    }
    								
    with
    Establishes a default object for a set of statements.
    with (oCar) {
    	if (crashed) {
    		alert("Your car, a "+maker+" "+model+", was in an accident.");
    	}
    }