不能访问此场景中的特定变量
Can't access a specific variable on this scenario
我不明白为什么我不能访问that.Friends.name
在这里(见下面的代码):
更新strong>
JS
function AClass(_Friends) {
var that = this;
this.Friends = _Friends;
this.doSomething = function() {
console.log(that.Friends.name); // Uncaught TypeError: Cannot read property 'name' of undefined
};
}
var A = new AClass({ name: 'toto' });
$('button').click(A.doSomething);