0
の「この」変化値Iは、次のコードをお持ちの場合:私はfunctionTwoのthis.functionOne()
内部を置き換えるためにSomething.prototype.functionOne()
を使用する必要はありませんきれいな方法でこれを書くことができますどのようにクリック
function Something() {
this.randomElement = $("#element");
}
Something.prototype = {
functionOne: function() {
console.log("hello");
},
functionTwo: function() {
this.randomElement.click(function(e) {
this.functionOne(); //this becomes pointed at randomElement
});
}
}
を? clickイベントはこの値を変更するので、