This关键字
This
what it 'this'
special variable that is created for every execution context.
this是在每一个执行上下文中产生的变量的,每一个执行上下文都有自己的this值。this不是静态的,它取决于函数如何被调用,它的值会在函数被调用的时候被赋予。
the value of 'this'
- Method: this = < Object that is calling the method >
- Simple function call: this = undefined
- Arrow function: this = < this of surrounding function > (父函数的this指向)
- Event Listener: this = < DOM element that the handle is attached to >
- new, call, apply, bind: this = self