this.height=1;
    this.size=Compute_size();
    this.height=3;
因为是同一个对象,所以你在给他付值之后变量了3,因此alert()的值也就是3了

解决方案 »

  1.   

    1.这里只是说b继承Component
    2.
    <script type="text/javascript">function Rectangle()
    {
        this.height=1;
        this.width=4;
        this.size=this.Compute_size();
        this.height=3;
    }
    Rectangle.prototype.Compute_size = function()
    {
        alert(this.height);
        return this.height*this.width;
    }
    var a=new Rectangle();
    document.write(a.size,"<br>");
      

  2.   

    1。但是调用函数Compute_size()的时候this.height的值是1呀,只是在调用函数后才被赋为3。为什么在调用函数的过程中显示3?
    2。如果只说b继承了Component,那么a是什么?
      

  3.   

    this.height=1;//此时为1
        this.width=4;
        this.size=this.Compute_size();
        this.height=3;//此时为3,最终为3
      

  4.   

    b是个类型(类),a只不过是b的prototype的一个引用