//es5.0严格模式的启动 在要执行es5.0js代码块最顶端加上"use strict";
/*"use strict";
function test() {
console.log(arguments.callee);
}
test();*/
/* var obj = {
name : 'obj'
}
var name = 'window';
function test(){
var name = 'scope';
var age = 18 ;
//with可以改变作用域链的最顶端
with(obj){
console.log(name);
console.log(age)
}
}
test();*/
/*//如何用with(){}解决命名空间的问题
var org = {
dp1:{
jc : {
name:"jicheng",
age:18
},
deng : {
name:"xiaodeng",
age:18
}
},
dp2:{
}
}
with(org.dp1.jc){
console.log(name);
console.log(age)
}
*/
/* with(document){
write('a');
}*/
//弊端,with(){}严重拖慢程序运行
/*arguments.callee arguments.caller 以及其他一些arguments不能在es5.0使用*/
/*"use strict";
function test() {
console.log(arguments.callee);
}
test();*/
/*es5.0中所有的变量未经声明都不允许使用,局部this必须被赋值
,赋值什么就是什么,因为预编译的时候this不在指向window,只有全局的this才是window*/
/*"use strict";
function test (){
console.log(this);
}
new test();//不new就是undefined*/
/*es5.0里面不允许出现重复的参数名和属性名,但是现在重复属性名不报错*/
/*"use strict";
function test(name,name){
console.log(name);
}
test(1,2)*/
/*eval() 能把里面的字符串当做代码来执行使用,但是es3.0里面不能使,
因为eval()能改变做作用域。*/
es5.0和es3.0有什么不同
最新推荐文章于 2023-11-12 17:24:41 发布