如题:eval函数中的this值是指的啥?
1 回答

犯罪嫌疑人X
TA贡献2080条经验 获得超4个赞
题主给的信息太少,不知道是不是题主想要的,先来第一个测试:
window.test = '2 + 2';eval(this.test); // 4
这个 eval 函数里面 的 this 是指向 window;
第二个测试:
window.test = '3 + 3';var t = 'this.test';eval(t); // "3 + 3"
eval 解析的字符串里面的 this 貌似也是指向 window。
以上代码在 chrome 下测试。
添加回答
举报
0/150
提交
取消