this:
1.函数预编译过程this————> window
function test(c) {
// var this=Object.create(test.prototype);
var a = 123;
function b() {
}
AO {
arguments: [1],
this: window,
c = 1,
a: undefined,
b: function() {}
}
}
test(1);
new test();
2.全局作用域里this ————> window
3.call/apply可以改变函数运行时this指向
4.obj.func();func()里面的this指向obj
谁调用了这个方法,这个this就指向谁
var obj = {
a: function() {
console.log(this.name);
},
name: 'abc',
}
obj.a();