本文共 235 字,大约阅读时间需要 1 分钟。
var a = 5; function test(){ a = 0; console.log(a); console.log(this.a); var a; console.log(a); } new test();
new test()时候,test内部会创建一个空对象,var this = {}, 最后return this;所有this指向{},此时a为undefined;
转载地址:http://wqtzi.baihongyu.com/