本帖最后由 moliu 于 2009-11-30 21:48:20 编辑

解决方案 »

  1.   

    function Point(dimension)       {              this.dimension = dimension;       }       //定义一个Point2D类型,“继承”Point类型       function Point2D(x, y)       {              this.x = x;              this.y = y;       }       Point2D.prototype.distance = function()       {              return Math.sqrt(this.x * this.x + this.y * this.y);       }       Point2D.prototype = new Point(2); //经过上面的设置,new Point(2)有distance 属性了吗?
      

  2.   

    this指的是 new Collection()的对象
      

  3.   

    关于this的最终回复,参见ECMA-262 10.2.3:
    The caller provides the this value. If the this value provided by the caller is not an object (including the case where it is null), then the this value is the global object.
    其他的参见Javascript Scope Chain相关资料。 
      

  4.   

    var B={m:5};
    function A(){} 
    A.prototype=B; 
    A.prototype.z=8; 
    b=new A(); 
    alert(b.z); //output 8 
    alert(b.m); //output 5 
    alert(B.z); //output 8 
    for(S in B)
    document.write(S+"="+B[S])//m=5z=8