次のコードでは、どのようにA.prototype.log
内部にアクセスできますB.prototype.log
か?
function A() {}
A.prototype.log = function () {
console.log("A");
};
function B() {}
B.prototype = Object.create(A.prototype);
B.prototype.constructor = B;
B.prototype.log = function () {
//call A.prototype.log here
console.log("B");
};
var b = new B();
b.log();
私はただ書くことA.prototype.log.call(this)
ができることを知っていますが、「プロトタイプチェーンの次の上位インスタンスのメソッド 'log' を呼び出す」のように、相対的な方法で呼び出すことができる、よりエレガントな方法があるのではないかと思いました。このようなことは可能ですか?