Child.prototype=new Parent();

  <script type="text/javascript">
 
    function Parent(){
        this.add=function(a,b){alert(a+b);}
    }

    Parent.prototype.sub=function(a,b){alert(a-b);}

    function Child(){
        //
    }

    Child.prototype=new Parent();

    var cls=new Child();
    cls.add(2,3);
    cls.sub(5,3);

  </script>

 

posted @ 2017-11-29 22:03  sky20080101  阅读(50)  评论(0)    收藏  举报