The switch statement of JavaScript

来源:互联网 发布:vb上视频教程全集 编辑:程序博客网 时间:2024/06/05 00:19

The struct of switch statement is as follows:

switch (expression) {  case value1:    //Statements executed when the result of expression matches value1    [break;]  case value2:    //Statements executed when the result of expression matches value2    [break;]  ...  case valueN:    //Statements executed when the result of expression matches valueN    [break;]  default:    //Statements executed when none of the values match the value of the expression    [break;]}

The function evaluate expression and get value from each case value or expression.When the result of expression matches one of them,Statements following this value executed.
**Attention!
The result of expression uses === to match value!
The result of expression uses === to match value!
The result of expression uses === to match value!
Important things need to repeat three times. :-)

For more information,see ECMA-262, 3rd edition.

0 0
原创粉丝点击