title: How to do inheritance with JavaScript object literals?
body: <p>Hello I have a problem with how to do inheritance while declaring object prototypes with object literal syntax.</p>
  
  <p>I have made two Fiddles to help you help me.</p>
  
  <ul>
  <li><a href="http://jsfiddle.net/ZSqQW/">Fiddle1, This one works</a> </li>
  <li><a href="http://jsfiddle.net/DnrU9/3/">Fiddle2, This one doesn't work</a></li>
  </ul>
  
  <p>This is my base class, almost all objects is defined in this way in my application:</p>
  
  <pre><code>Base = function(param){
      this.init(param);
  }
  Base.prototype = {
      init: function(param){
          this.param = param;
      },
      calc: function(){
          var result = this.param * 10;
          document.write("Result from calc in Base: " + result + "&lt;br/&gt;");
      },
      calcB: function(){
          var result = this.param * 20;
          document.write("Result from calcB in Base: " + result+ "&lt;br/&gt;");
      }
  }
  </code></pre>
  
  <p>This is how I succeed extending and overriding methods in Base:</p>
  
  <pre><code>Extend = function(param){
      this.init(param);
  }
  Extend.prototype = new Base();
  
  Extend.prototype.calc = function(){
      var result = this.param * 50;
      document.write("Result from calc in Extend: " + result+ "&lt;br/&gt;");
  }
  </code></pre>
  
  <p>But I wanted to use the same style as the rest of the application so I started playing around with object literals but it is driving me nuts eagerly cheered on by eclipse and firebug with its nonsense response to my syntax. </p>
  
  <p>Now on to the question of how do I convert my succeeded extension code to object literal style?
  Here is one of many attempts (it don't compile but will give you an rough idea how I want the code to look like.)</p>
  
  <pre><code>Extend = function(param){
      this.init(param);
  }
  Extend.prototype = {
      : new Base(),
      calc: function(){
          var result = this.param * 50;
          document.write("Result from calc in Extend: " + result+ "&lt;br/&gt;");
      }
  }
  </code></pre>