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! ^_^