答案:switch Statement<br>
Enables the execution of one or more statements when a specified expression's value matches a label.<br>
<br>
switch (expression) {<br>
case label :<br>
statementlist<br>
case label :<br>
statementlist<br>
...<br>
default :<br>
statementlist<br>
} <br>
<br>
Arguments<br>
expression<br>
<br>
The expression to be evaluated.<br>
<br>
label<br>
<br>
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.<br>
<br>
statementlist<br>
<br>
One or more statements to be executed.<br>
<br>
Remarks<br>
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. <br>
<br>
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.<br>
<br>
Execution flows through a switch statement as follows: <br>
<br>
Evaluate expression and look at label in order until a match is found. <br>
If a label value equals expression, execute its accompanying statementlist. <br>
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. <br>
If no label equals expression, go to the default case. If there is no default case, go to last step. <br>
Continue execution at the statement following the end of the switch code block. <br>
Example<br>
The following example tests an object for its type. <br>
<br>
function MyObject() {<br>
...}<br>
<br>
switch (object.constructor){<br>
case Date:<br>
...<br>
case Number:<br>
...<br>
case String:<br>
...<br>
case MyObject:<br>
...<br>
default: <br>
...<br>
}<br>
Requirements<br>
Version 3<br>
<br>
with Statement<br>
Establishes the default object for a statement. <br>
<br>
with (object)<br>
statements <br>
<br>
Arguments<br>
object<br>
<br>
The new default object.<br>
<br>
statements<br>
<br>
One or more statements for which object is the default object.<br>
<br>
Remarks<br>
The with statement is commonly used to shorten the amount of code that you have to write in certain situations. In the example that follows, notice the repeated use of Math. <br>
<br>
x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) <br>
y = Math.tan(14 * Math.E)<br>
When you use the with statement, your code becomes shorter and easier to read: <br>
<br>
with (Math){<br>
x = cos(3 * PI) + sin (LN10) <br>
y = tan(14 * E)<br>
}<br>
Requirements<br>
Version 1
上一个:在javascript 里面有没有检查日期格式的函数?
下一个:asp的cookie本身不设置的话默认的是application的path=/,所以不设关系不大,expires要设。给你netscape...