Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. object1 = function(){
  2.   console.log('subAction1');
  3.   console.log('subAction2'); //how can I change this log in object2??
  4.   console.log('subAction3');
  5. }
  6.  
  7. Inheritance_Manager = {};
  8. Inheritance_Manager.extend = function(subClass, baseClass) {
  9.     function inheritance() { }
  10.     inheritance.prototype = baseClass.prototype;
  11.     subClass.prototype = new inheritance();
  12.     subClass.prototype.constructor = subClass;
  13.     subClass.baseConstructor = baseClass;
  14.     subClass.superClass = baseClass.prototype;
  15. }
  16.  
  17. object2 = function() {
  18.     object2.baseConstructor.call();
  19.     console.log('action2');
  20. }
  21. Inheritance_Manager.extend(object2, object1);
  22.  
  23. var test1 = new object1(); //logs: subAction1, subAction2, subAction3
  24. var test2 = new object2(); //logs: subAction1, subAction2, subAction3, action2
  25.  
  26. //but I want object2 to log something like: subAction1, changedAction!!!, subAction3, action2"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement