<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script>
function Rect(w,h){
this.width=w;
this.height=h;
this.area=function(){
return this.width*this.height;
}
}
var r= new Rect(4,8);
alert("长"+r.width+"高"+r.height+",面积:"+r.area());
</script>
</body>
</html>
运行之后的效果如下: