use 'strict'; function Student(props) { if (!props) props = {}; this.name = props.name || 'unnamed'; this.age = props.age || 23; Student.prototype.hello = function() { return 'hello!,' + this.name; } } function PrimaryStudent(props) { Student.call(this, props); this.grade = props.grade || 0; PrimaryStudent.prototype.say = function() { return 'say!,' + this.name; } } function inherits(child, parent) { function F() {}; F.prototype = parent.prototype; child.prototype = new F(); child.prototype.constructor = child; } function inherits2(child, parent) { child.prototype = new parent(); child.prototype.constructor = child; } inherits2(PrimaryStudent, Student); var ps = new PrimaryStudent({ name: 'XXXX', grade: 100 });
Sign in to make a reply
importNew_yy