ES5的使用eval,()

<script type="text/javascript">


//es5严格模式
//当es3和es5一些方法存在冲突,要不使用es5方法去解决,要不默认用es3的方法去解决
// function demo() {
// console.log(arguments.callee);
// }
// demo();

// "use strict"//为什么要使用字符串来表示 向低版本不报错,向高版本进行兼容
// function test() {
// console.log(arguments.callee);
// }
// test();

//with的使用
// var obj = {
// name : "obj"
// }
// var name = 'window';

// function test() {
// var name = 'scope';
// with(obj) {//with方法 指向作 用域的最顶端
// console.log(name);
// }
// }
//test();

// var org = {
// dp1 : {
// jc : {
// name : 'abc',
// age : 123
// },
// deng : {
// name : "xiaodeng",
// age : 234
// }
// },
// dp2 : {

// }
// }
// with (org.dp1.jc) {
// console.log(name);//abc
// }
// with(org.dp1.deng) {
// console.log(name);//xiaodeng
// }

// with(document) {
// write('a');//a
// }

// "use strict"
// function Test() {
// console.log(this);
// }
// new Test();

//eval()
//1.改变作用域 2.转化成123 3。es3不能使用
// eval('console.log('123')');//123


</script>

posted on 2022-08-08 13:39  爱前端的小魏  阅读(117)  评论(0编辑  收藏  举报

导航