Microsoft® JScript switch Statement |
Language Reference Version 3 |
Enables the execution of one or more statements when a specified expression's value matches a label.
switch (expression) {
case label :
statementlist
case label :
statementlist
...
default :
statementlist
}The switch statement syntax has these parts:
Part Description expression The expression to be evaluated. label An identifier to be matched against expression. If label === expression, execution starts with the statementlist immediately after the colon. and continues until it encounters either a break statement, which is optional, or the end of the switch statement. statementlist One or more statements to be executed.
Use the default clause to provide a statement to be executed if none of the label values matches expression. It can appear anywhere within the switch code block.Zero or more label blocks may be specified. If no label matches the value of expression, and a default case is not supplied, no statements are executed.
Execution flows through a switch statement as follows:
The following example tests an object for its type:
- Evaluate expression and look at label in order until a match is found.
- If a label value equals expression, execute its accompanying statementlist.
Continue execution until a break statement is encountered, or the switch statement ends. This means that multiple label blocks are executed if a break statement is not used.- If no label equals expression, go to the default case. If there is no default case, go to last step.
- Continue execution at the statement following the end of the switch code block.
function MyObject() { ...} switch (object.constructor){ case Date: ... case Number: ... case String: ... case MyObject: ... default: ... }
© 1997 by Microsoft Corporation. All rights reserved.
file: /Techref/language/jscript/js766.htm, 4KB, , updated: 1997/9/30 02:45, local time: 2024/11/29 17:26,
3.133.124.23:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/Techref/language/jscript/js766.htm"> switch Statement</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.