function A(a,b)
{
   this.a = a;
   this.b = b;
}B.prototype.superclass = A;function B(a,b,c,d)
{
   this.superclass(a,b);
   this.c = d;
   this.d = d;
}
这是书上的一个例子,但是我测试的时候说“this.superclass is not a function”,请问那里出了问题?

解决方案 »

  1.   

    <script language="javascript">
    function A(a,b) 

      this.a = a; 
      this.b = b; 

    B.prototype.superclass = A; 
    function B(a,b,c,d) 

      this.superclass(a,b); 
      this.c = d; 
      this.d = d; 

    var B1= new B(1,2,3,4);
    alert(B1.a);//1
    </script>
      

  2.   

    你如果是直接引用 B 函数  就改成new 一个B对象 再调用 
      

  3.   

    测试的时候直接new 一个B对象。1楼所示,运行正常啊,没什么问题