# this
1. 总结this的指向的规律
2. 改变this指向的方式
3. 下面代码的执行结果为
```js
function fn2(){
    console.log(this.n)
    var n='n'
    this.n=10
    console.log(n)
}
var obj={fn2:fn2, n:1}
fn2()
obj.fn2()
console.log(obj.n, window.n)

```
4.下面代码的执行结果为
```js

function f(){console.log(this)}

var obj={
    fn: (function(){
        console.log(this.f)
        // return this.f
    })(),
    f: function(){console.log(this)}
}
f()
obj.f()

```

5. 下面代码的执行结果为
```js
var n = 10
var obj1={
    n:1,
    f:function(){this.n++; n=this.n++}
}

obj1.f()
console.log(n)
console.log(obj1.n)
window.setTimeout(obj1.f, 1000)

```


6. 下面代码的执行结果为
```js
console.log(getA)
if('a' in window){
    var a = ''
    function getA(a){
        a = a||this.a
        console.log(this.a)
    }
    getA(a)
}
```


7. 下面代码执行结果为
```js
const obj1 = {
    nickName: 'qianguyihao',
    age: 28,
};
function fn1() {
    console.log(this);
    console.log(this.nickName);
}
fn1.call(this);

```

8. 下面代码的执行结果为
```js
var obj1 = {
    nickName: 'qianguyihao',
    age: 28,
};

function fn1(a, b) {
    console.log(this);
    console.log(this.nickName);
    console.log(a + b);
}

fn1.call(obj1, 2, 4);


```

9.下面代码的执行结果为
```js
function Father(myName, myAge) {
    this.name = myName;
    this.age = myAge;
}

function Son(myName, myAge) {
    Father.call(this, myName, myAge);
}

const son1 = new Son('hello', 28);
console.log(JSON.stringify(son1));
```

10.把上面7,8,9 改成apply语法

13.把上面7,8,9 改成bind语法
