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