<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>

运行之后的效果如下:

Javascript运用函数计算正方形的面积

相关文章:

  • 2021-11-17
  • 2022-01-26
  • 2022-02-21
  • 2022-12-23
  • 2021-12-19
  • 2021-07-30
猜你喜欢
  • 2021-12-12
  • 2022-03-02
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案