| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | <!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta http-equiv="X-UA-Compatible" content="IE=edge">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title></head><body>  <script>    // var a = 1    // var obj = {    //   a: 3,    //   fun: function () {    //     return () => { console.log(this.a) }    //   }    // }    // obj.fun()()    // 3  3  3    // var a = 1    // var obj = {    //   a: 3,    //   fun: () => {    //     return function () {    //       console.log(this.a)    //     }    //   }    // }    // obj.fun()()    //3  3  3  3  1    var name = 'window'    function Person(name) {      this.name = name      this.foo1 = function () {        console.log(this.name);      }      this.foo2 = () => {        console.log(this.name)      }      this.foo3 = function () {        return function () {          console.log(this.name);        }      }      this.foo4 = function () {        return () => {          console.log(this.name);        }      }    }    var person1 = new Person('person1')    var person2 = new Person('person2')    person1.foo1() //p1    person1.foo1.call(person2) //p2    person1.foo2() // p1     person1.foo2.call(person2)//p1    person1.foo3()() //window    person1.foo3.call(person2)() // window    person1.foo3().call(person2) //p2     person1.foo4()() // p1     person1.foo4.call(person2)() // p2    person1.foo4().call(person2) //p1    //p1 p2 p1 p1 win win p2 p1 p2 p1  </script></body></html>
 |