最近在 stackoverflow 看到了一个问题: this 是如何工作的。要想解释这个问题,需要对 JavaScript Exuction 和 JavaScript Scope 有足够的了解。
按照 JavaScript Specification
Initial global execution context
Entering eval code
Entering function code
Arrow function
Arrow functions don’t have their own this…. binding. Instead, those identifiers are resolved in the lexical scope like any other variable. That means that inside an arrow function, this…refer(s) to the values of this in the environment the arrow function is defined in.