Javascript代码错误

meceky 2009-07-29 08:52:55

<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)此句有错误!怎么修改啊
...全文
50 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
浴火_凤凰 2009-07-29
  • 打赏
  • 举报
回复
var tt = new ImmutableRectangle(4,7);
cpp2017 2009-07-29
  • 打赏
  • 举报
回复
这个错误我也经常犯,常见的就是

int i = .....;

经常找不出来.因为这个写法
太熟悉了
FangYANYI 2009-07-29
  • 打赏
  • 举报
回复
function ImmutableRectangle(w,h) {
this.getWidth = function() { return w; }
this.getHeight = function() { return h; }
}
改成
IImmutableRectangle function(w,h)
{
this.getWidth = function() { return w; }
this.getHeight = function() { return h; }
};
meceky 2009-07-29
  • 打赏
  • 举报
回复
晕!写C#习惯了。。。看了半天也没有看出来怎么回事!!!
cpp2017 2009-07-29
  • 打赏
  • 举报
回复
var tt = new ImmutableRectangle(4,7);

js中没有显示变量类型的.

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧