JavaScript-基础篇-This指向问题-下

2. Arrow function 的this指向

上篇回顾:

1. 默认绑定: console.log(this=== window)  ==> true 2. 隐式绑定: (谁呼叫就指向谁) :3. 显式绑定: call, apply, bind4. new 绑定规则;

箭头函式的this

物件中的巢状函式

    let a = 0    let obj = {        a : 'obj',        foo(){        let that = this;        console.log(this);        function test(){            console.log(this); // // window            console.log(that); // obj        }        test()         // 也可以通过这种方式使 this 指向 obj 

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章