JS 中 this 的绑定规则与优先级判断
阅读下面的代码,说出每个 console.log 的输出,并解释原因: const obj = { name: ‘obj’, getName() { return this.name; }, getNameArrow: () => this.name }; const fn = obj.getName; console.log(obj.getName()); console.log(fn()); console.log(obj.getNameArrow()); console.log(obj.getName.call({name:‘ctx’})); function P(){ this.x = 1; } console.log(new P().x); 要求:明确说明 this 的绑定优先级,以及严格模式下的差异。