title: Preventing infinite recursion when using Backbone-style prototypal inheritance
body: <p>I'm using an extend function adapted from Backbone (identical apart from a few changes to comply with my employer's naming conventions) to implement prototypal inheritance. After setting up the following structure (much simplified below) I get an infinite loop.</p>
  
  <pre><code>Graph = function () {};
  Graph.extend = myExtendFunction;
  Graph.prototype = {
     generateScale: function () {
         //do stuff
     }
  }
   // base class defined elsewhere
  UsageGraph = Graph.extend({
     generateScale: function () {
         this.constructor._super.generateScale.call(this); // run the parent's method
         //do additional stuff
     }
  })
  
  ExcessiveUsageGraph = Graph.extend({
     // some methods, not including generateScale, which is inherited directly from Usage Graph
  })
  
  var EUG = new ExcessiveUsageGraph();
  EUG.generateScale(); // infinite loop
  </code></pre>
  
  <p>The loop is happening because <code>ExcessiveUsageGraph</code> goes up the prototype chain to <code>UsageGraph</code> to run the method, but <code>this</code> is still set to an instance of <code>ExcessiveUsageGraph</code> so when I use <code>this.constructor._super</code> to run the parent method it also goes one step up the chain to <code>UsageGraph</code> and calls the same method again.</p>
  
  <p>How can I reference parent methods from within a Backbone-style prototype and avoid this kind of loop. I also want to avoid referring to parent classes by name if possible.</p>
  
  <p><em>edit</em> <a href="http://jsfiddle.net/wheresrhys/wtsBP/" rel="noreferrer">Here's a fiddle demonstrating that this happens in Backbone</a> </p>