【发布时间】:2011-06-20 16:10:31
【问题描述】:
在我看到的一个 JavaScript 文件中:
function Somefunction(){
var that = this;
...
}
声明that并将this分配给它的目的是什么?
【问题讨论】:
-
var self = this?的可能重复
-
箭头函数不需要“this”和“that”hack。使用箭头函数“this”按预期工作。有关详细信息,请参阅此处ES6 In Depth: Arrow functions
-
基于上下文here的神秘这种行为的一个很好的解释
-
最新和更新的解释可以找到here
标签: javascript this