Functions as Methods

施英哲
2023-12-01

When a function is invoked as a function rather that as a method, the this keyword refers to the global
object. Confusingly, this is true even when a nested function is invoked (as a function) within a containing
method that was invoked as a method: the this keyword has one value in the containing function but
(counterintuitively) refers to the global object within the body of the nested function.
Note that this is a keyword, not a variable or property name. JavaScript syntax does not allow you to
assign a value to this .

 类似资料:

相关阅读

相关文章

相关问答