解决方案 »

  1.   

    那你想让this指向哪阿?
    function TestClass(){
           this.property = true;
       }
       TestClass.prototype.getFatherValue = function(){
          return this.property;
       };
       var test = new TestClass();
       window.alert(test.constructor.prototype.getFatherValue.call(test));
      

  2.   

    this不是指向TestClass吗?上面的getValue()方法写错了,应该是getFatherValue()。prototype是test的原型,getFatherValue()在prototype中,按道理是可以通过test.prototype.getFatherValue()来访问的。
      

  3.   


    举个简单的例子:TestClass是你师父,getFatherValue是你师父赚钱的能力。
    你师父教会你赚钱的能力 test = new TestClass(); 但你不能直接去拿你师父的钱:test.prototype.getFaterValue,你得自己去拿钱。test.getFatherValue。而且根据js的规则,你想再找个徒弟,那需要经过多次的处理。一般叫继承。
    这是一条js语法规则,这样做的目的,就是为了编程完全不能让实例化的对象test直接去改变父类的getFatherValue的方法。这是我个人的理解,更管方的参考上面的图,或javascript高级程序设计 第三版 148页 理解原型对象。
      

  4.   

    谢谢大家的指教,根据大家的答案和参考javascript高级程序设计,总结如下:
    1.prototype属性是构造函数(TestClass())的属性,实例test没有prototype属性。
    2.实例有一个指针[[prototype]]指向构造函数的prototype。
    3.可以通过两种方法访问构造函数的prototype:通过test的proto属性和Object.getPrototypeOf(test)