1
如果是,为什么这段代码不会提醒任何事情?做javascript switch语句case允许使用表达式
<html>
<head>
<script type="text/javascript">
switch ("hello world") {
case "hello" + " world":
alert("Greeting was found.");
break;
case "goodbye":
alert("Closing was found.");
break;
default:
alert("Unexpected message was found.");
}
</head>
</html>
无论如何,这个开关有什么意义?为什么要将常量与其他常量进行比较? – 2011-03-10 14:01:12
它适用于Chrome。 – 2011-03-10 14:02:55
按我的预期工作,ff3.6 – meouw 2011-03-10 14:03:15