<script language = "javascript" type = "text/javascript">
function ImmutableRectangle(w,h) {
this.getWidth = function() { return w; }
this.getHeight = function() { return h; }
}
ImmutableRectangle.prototype.area = function() {
return this.getWidth() * this.getHeight();
}
ImmutableRectangle tt = new ImmutableRectangle(4,7)
document.write(tt.area());
// ImmutableRectangle hhh = new ImmutableRectangle(4,5);
</script>ImmutableRectangle tt = new ImmutableRectangle(4,7)此句有错误!怎么修改啊
this.getWidth = function() { return w; }
this.getHeight = function() { return h; }
}
改成
IImmutableRectangle function(w,h)
{
this.getWidth = function() { return w; }
this.getHeight = function() { return h; }
};
太熟悉了