固定内层函数的 this

index.js

const obj = {
  foo() {
    console.log(this); // obj
    const self = this;
    const bar = (function () {
      console.log(self); // obj
    })();
  },
};

obj.foo();
原文地址:https://www.cnblogs.com/aisowe/p/15250031.html