0
なぜChild.prototype.constructor
プロパティを継承後にChild
に設定する必要があるのですか。例継承を使用してコンストラクタフィールドをオーバーライドする理由
function Parent(a){
this.a = a;
}
function Child(a, b){
Parent.call(this. a);
this.b = b;
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child // 1)**
のために私たちは、この// 1) **
ラインを必要とするのはなぜコンストラクタのインスタンスが// 1) **
ライン
なく、同じになりますか?見ての通り
[なぜプロトタイプのコンストラクタを設定する必要がありますか?](https://stackoverflow.com/questions/8453887/why-is-it-necessaryプロトタイプ生成者を設定するための-to-set-the-prototype-constructor) –