简体   繁体   English

使用严格:如何测试?

[英]Use Strict : How to test it?

I have been reading people recommending using "use strict" option. 我一直在阅读推荐使用“use strict”选项的人。 As mentioned here 如前所述这里

every major browser supports strict mode in their latest version, including Internet Explorer 10 and Opera 12. I wanted to test it with IE10 and i have following code segemnt. 每个主流浏览器都支持最新版本的严格模式,包括Internet Explorer 10和Opera 12.我想用IE10测试它,我有以下代码segemnt。 IE 10 /FF did not gave any error message. IE 10 / FF没有给出任何错误消息。 What am i missing ? 我错过了什么? How do i test that "use strict" is actually working if i make any mistake ? 如果我犯了任何错误,我如何测试“use strict”实际上是否正常工作?

<html>
<head>
<script type = "text/javascript">
"use strict";
function doSomething(value1, value1, value3) {
     alert('hello');
}
</script>
</head>
<body>
hello
</body>
</html>

You can see in this example that Chrome actually complains about the duplicate argument name: 您可以在此示例中看到Chrome实际上抱怨重复的参数名称:

http://jsfiddle.net/vANfY/ http://jsfiddle.net/vANfY/

firefox throws 'duplicate formal argument value1', firefox抛出'重复的正式参数value1',

IE10 throws 'Duplicate formal parameter names not allowed in strict mode' IE10抛出'严格模式下不允许重复的形式参数名'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM