首页 > 其他 > 详细

组合方式实现继承:构造函数、原型链

时间:2020-04-04 14:46:55      阅读:56      评论:0      收藏:0      [点我收藏+]
 /*
    组合方式实现继承:构造函数、原型链
     */
    function Parent3() {
        this.name = ‘Parent 的属性‘;
        this.arr = [1, 2, 3];
    }

    function Child3() {
        Parent3.call(this); //【重要1】执行 parent方法
        this.type = ‘Child 的属性‘;
    }
    Child3.prototype = new Parent3(); //【重要2】第二次执行parent方法

    var child = new Child3();

组合方式实现继承:构造函数、原型链

原文:https://www.cnblogs.com/weichenji0/p/12631633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!