This关键字

This

what it 'this'

special variable that is created for every execution context.

this是在每一个执行上下文中产生的变量的,每一个执行上下文都有自己的this值。this不是静态的,它取决于函数如何被调用,它的值会在函数被调用的时候被赋予。

the value of 'this'

  1. Method: this = < Object that is calling the method >
  2. Simple function call: this = undefined
  3. Arrow function: this = < this of surrounding function > (父函数的this指向)
  4. Event Listener: this = < DOM element that the handle is attached to >
  5. new, call, apply, bind: this = self
posted @ 2023-02-15 14:37  kihyun  阅读(15)  评论(0编辑  收藏  举报