//  圣杯模式
        //  为了son继承father原型上的东西,还可以修改自己原型上的东西,对father原型不影响。
        function inherit(Target,Origin){ 
            function F (){};// 函数F作为一个中间层,上连father,下连Son,使两函数互不干扰
            F.prototype = Origin.prototype;
            Target.prototype = new F();
            Target.prototype.constuctor = Target;
            // son原型归位
            Target.prototype.uber = Origin.prototype;
        }
        Father.prototype.lastName = "Deng";
        function Father(){}
        function Son(){}
        inherit(Son,Father);
        // 运行函数,形参实参相统一
        var son = new Son();
        var father = new Father();

 

相关文章:

  • 2021-10-21
  • 2021-07-21
  • 2022-02-07
  • 2021-10-30
  • 2021-07-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
相关资源
相似解决方案