constructor chain
by regepan
JavaScript
// ベースクラス
function Rectangle(w, h) {
this.width = w;
this.height = h;
}
// サブクラス
function PositionedRectangle(x, y, w, h) {
// ここがコンストラクタチェーン
Rectangle.call(this, w, h);
this.x = x;
this.y = y;
}
// this.widthとthis.heightが
// PositionedRectangleに設定されている
console.log(new PositionedRectangle(1,2,3,4));