This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 3rd, 2013  |  syntax: JavaScript  |  size: 0.89 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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"
clone this paste RAW Paste Data