js原型继承四步曲

<sctript>

    //1.创建父类

    function Parent(){

        this.name = name;

    }

    Parent.prototype.age = 20;

    //2.创建子类

    function Child(){

    Parent.call(this,"zhangsan");

    }

    //3.确立继承关系

    Child.prototype = Object.create(Parent.prototype);

    //4.改变构造器

    Chils.prototype.constuctor = Child;

</script>

多多指教,我还是前端小生
原文地址:https://www.cnblogs.com/yangslin/p/7899945.html