var a = {
text : 3,
logText : function () {
console.log(this.text);
},
callLogText : function() {
logText();
}
};
a.callLogText();
これにより、ReferenceError: logText is not definedエラー メッセージが生成されます。
代わりにthis、logText()メソッドに接頭辞を付ければ問題ありません。エラー メッセージは表示されません。
var a = {
text : 3,
logText : function () {
console.log(this.text);
},
callLogText : function() {
this.logText();
}
};
私は本当に理由を理解することはできません。