function(){
"use strict";
//....往下的代码都会开启js strict 模式
}
use js strict mode 的好处:
point1-检查json中重复的键:
e.g :
{
a:1,a:1 //会报错了
}
point2-检查函数中重复的参数:
function(arg1,arg1){}// prompt incorrect arguments
point3-check the undeclare variable:
a = 1;// prompt
point4-restrict the arguments object :
function test(arg){
arguments[0] = 1;
alert(arg);
}
test(2)//2, not 1. limit the arguments object overwrite.
brief summary:
暂时只想到以上4点了,大家有更多细节可以给我留言。THX! ^_^
最后
以上就是健忘钢笔最近收集整理的关于javascript中写插件用use strict的好处的全部内容,更多相关javascript中写插件用use内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复