sashomaga

js inheritance

Feb 10th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Inheritance_Manager = {};  
  2.  
  3. Inheritance_Manager.extend = function (subClass, baseClass) {
  4.     function inheritance() { };
  5.     inheritance.prototype = baseClass.prototype;
  6.     subClass.prototype = new inheritance();
  7.     subClass.prototype.constructor = subClass;
  8.     subClass.baseConstructor = baseClass;
  9.     subClass.superClass = baseClass.prototype;
  10. }
  11.  
  12. function Human(age, grade){
  13.   this.age = age;
  14.   this.grade = grade
  15. }
  16.  
  17. function Student(age, gender, grade){
  18.   Student.baseConstructor.call(this, age, grade);
  19.   this.gender = gender;
  20. }
  21.  
  22. Inheritance_Manager.extend(Student, Human);
Advertisement
Add Comment
Please, Sign In to add comment