一段代码让我很困惑?
function Polygon(iSides) {
this.sides = iSides;
if (typeof Polygon._initialized == "undefined") {
Polygon.prototype.getArea = function () {
return 0;
}
Polygon._initialized = true;
}
}
function Triangle(iBase, iHeight) {
Polygon.call(this, 3);
this.base = iBase;
this.height = iHeight;
if (typeof Triangle._initialized == "undefined") {
Triangle.prototype = new Polygon();
Triangle.prototype.getArea = function () {
return 0.5 * this.base * this.height;
};
Triangle._initialized = true;
}
}
//这里的this代表的是什么对象 还有这段代码错在什么地方。 本人JS刚学的菜鸟 求各位大牛 解释清楚点
Polygon.call(this, 3);
this.base = iBase;
this.height = iHeight;