0
プロトタイプ継承関数作成パターンは2種類あります。protypal継承のメタオブジェクトは上記のES5を意味しますか?
Function.prototype.inherit = function(base) {
function Meta() {};
Meta.prototype = base;
this.prototype = new Meta();
}
と
Function.prototype.inherit = function(base) {
this.prototype = new base();
}
元実装がある余分な何もするらしいしません!間にMeta関数がある場合、そのユースケースは何ですか? ES5で
function Base() {
console.log("This should not be called when inheriting!");
}
// If you use `new Base()` as a prototype, an unwanted message is logged
、これはObject.create
として内蔵されています:コンストラクタを呼び出すことによって発生する可能性がある副作用を避けるためにそこにあるMeta
機能の
1つの観測n形式アプローチは、ノード6.10ではもう機能しません。 –