标签:总结 安全 无效 rabl 效率 this 基于 can jsb
"use strict"; x = 3.14; // 报错 (x 未定义)
"use strict"; myFunction(); function myFunction() { y = 3.14; // 报错 (y 未定义) }
x = 3.14; // 不报错 myFunction(); function myFunction() { "use strict"; y = 3.14; // 报错 (y 未定义) }
"use strict";
<script> "use strict"; console.log("这是严格模式。"); </script> <script> console.log("这是正常模式。");kly, it‘s almost 2 years ago now. I can admit it now - I run it on my school‘s network that has about 50 computers. </script>针对单个函数调用,
function strict(){ "use strict"; return "这是严格模式。"; } function notStrict() { return "这是正常模式。"; }脚本的变通写法
(function (){ "use strict"; // some code here })();
"use strict"; var v = 1; with (o){ // 语法错误 v = 2; }
"use strict"; var x = 2; console.info(eval("var x = 5; x")); // 5 console.info(x); // 2
function f(){ return !this; } // 返回false,因为"this"指向全局对象,"!this"就是false function f(){ "use strict"; return !this; } // 返回true,因为严格模式下,this的值为undefined,所以"!this"为true。使用构造函数时,如果忘了加new,this不再指向全局对象,而是报错
function f(){ "use strict"; this.a = 1; }; f();// 报错,this未定义
function f1(){ "use strict"; f1.caller; // 报错 f1.arguments; // 报错 } f1();
"use strict"; var x; delete x; // 语法错误 var o = Object.create(null, {‘x‘: { value: 1, configurable: true }}); delete o.x; // 删除成功函数必须声明在顶层
"use strict"; if (true) { function f() { } // 语法错误 } for (var i = 0; i < 5; i++) { function f2() { } // 语法错误 }
"use strict"; var f = function() { return arguments.callee; }; f(); // 报错
标签:总结 安全 无效 rabl 效率 this 基于 can jsb
原文地址:http://blog.csdn.net/xiangzhihong8/article/details/53063928