Specifications
break red;
}
}
}
case
switch ( expression ) {
case Value:
Statements;
break;
default:
DefaultStatements;
break;
}
This keyword is used in Switch statements. For each possible value that a Switch statement's
expression may evaluate to, one case may be written, (but see default.) If a case's literal value
(Value) matches the value of the Switch statement's expression, then that case's statements
(Statements) are executed.
Normally a case's statements are terminated by a break statement which causes execution to
pass to the end of the Switch statement.
See Switch for an example.
catch
try {
Statements;
}
catch( exception ) {
ExceptionStatements;
}
This keyword is used in try statements. If an exception occurs, then the ExceptionStatements in
a matching catch block are executed.
Catch blocks come in two varieties, unqualified and qualified. An unqualified catch block has
the form:
catch ( e ) {
/* statements */
}
and a qualified catch block has the form:
catch ( e if e instanceOf RangeError ) {
/* statements */
}
The possible exception types are:
• EvalError -- the result of a failed eval() call.
• RangeError -- a result that is out of range, example: an array index to an element that is not
in the array.
• TypeError -- an attempt to perform an operation on an object of an inappropriate type.
• User defined exceptions -- exceptions that are objects of a user-defined type.
See try for an example. Also, see throw.
401
Enfocus Switch 10