0
考慮下面的代碼:如何在另一個類(ClassB)內實例化一個類(ClassA)並將ClassA對象用作JavaScript中ClassB的屬性?
function Coord(x, y) {
this.x = x;
this.y = y;
}
function Ellipse() {
this.Text = Text;
this.Cx = Cx;
this.Cy = Cy;
this.Rx = Rx;
this.Ry = Ry;
}
現在在功能Ellipse
而不是使用Cx
,Cy
等我想實例化功能Coord
每對取得成就如下:
function Coord(x, y) {
this.x = x;
this.y = y;
}
function Ellipse() {
this.Text = Text;
Coord C = new C(); // where C has its own properties x and y
Coord R = new R(); // where R has its own properties x and y
}