面向对象编程

    function inherits(Child,Parent){
        var F = function(){};
        F.prototype = Parent.prototype;
        Child.prototype = new F();
        Child.prototype.constructor = Child;
    }
    function Student(props){
        this.name = props.name || 'WangXiang';
    };
    Student.prototype.hello = function(){
        alert('Hello,' + this.name + '!')
    };
    function PrimaryStudent(props){
        Student.call(this,props);
        this.grade = props.grade || 43;
    }
    inherits(PrimaryStudent,Student);
    PrimaryStudent.prototype.getGrade = function(){
        return this.grade;
    }
原文地址:https://www.cnblogs.com/hzx-5/p/9589127.html