var small, big;
if(scrollLeft < 1000){
//add some token to the page
//call it small
}
switch (//reference token/) {
case (small):
//do stuff
break;
case (big):
//do stuff;
break;
}
< span style=" font - family:宋体;"> 37道明> < /女士
< span style=" font - family:宋体;"> 73 ms td > < /
< span style=" font - family:宋体;"> 68 ms td > < /
< span style=" font - family:宋体;"> 184 ms td > < /
< span style=" font - family:宋体;"> 73 ms td > < /
< span style=" font - family:宋体;"21女士> < / td >
眼前的
虽然是间接的
< font style=" font - family:宋体;
< font - family:宋体> " font - family:宋体;
3. . " font - family:宋体;
< span style=" font - family:宋体;
6 . . " font - family:宋体;
. " font - family:宋体;
20.9
.
< font - family:宋体 . font - family:宋体;
switch-range2
.
. " font - family:宋体;
9 .
. .
switch-indirect-array
< font - family:宋体 . font - family:宋体;
6 . . .
. " font - family:宋体;
. font - family:宋体;
4.
. < d style="text-align: center;
>10.0
4. . " font - family:宋体;
2. . " font - family:宋体;
array-binary-switch
. " font - family:宋体;
6. . " font - family:宋体;
9. . " font - family:宋体;
. " font - family:宋体;
.
.
2012年的测试在Windows 7 32位上执行,版本如下:Chrome 21.0.1180.89m, Firefox 15.0, Opera 12.02, MSIE 9.0.8112, Safari 5.1.7。节点在Linux 64位盒子上运行,因为Node for Windows上的计时器分辨率是10ms而不是1ms。
switch (true) {
case (0 <= val && val < 1000): /* do something */ break;
case (1000 <= val && val < 2000): /* do something */ break;
...
case (29000 <= val && val < 30000): /* do something */ break;
}