title: JavaScript inheritance with _.extend()
body: <p>Whats the difference between </p>
  
  <pre><code>Employee.prototype = Object.create(Person.prototype);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>_.extend(Employee.prototype, Person.prototype);
  </code></pre>
  
  <p>Both give similar results (output), but the underscore method seems to add the Person.prototype to the Employee.constructor.prototype, and quite abit extra stuff here and there, why? </p>
  
  <p>pure JS</p>
  
  <p><img src="https://i.stack.imgur.com/b7v6d.png" alt="enter image description here"></p>
  
  <p>underscoreJS</p>
  
  <p><img src="https://i.stack.imgur.com/07KPA.png" alt="enter image description here"></p>
  
  <p>A nice side effect of <code>_.extend</code> is I can easily do multiple inheritance: seems like it doesnt make the prototype chain longer too ... </p>
  
  <pre><code>_.extend(Employee.prototype, Person.prototype);
  _.extend(Employee.prototype, {
      doSomething: function() {
          return "hi ...";
      }
  });
  </code></pre>
  
  <p>But ... </p>
  
  <p><img src="https://i.stack.imgur.com/ikP2K.png" alt="enter image description here"></p>
  
  <p>Why is there 2 sayHi and doSomething functions? (actually its the same when I just do 1 extend). </p>
  
  <p><strong><a href="http://jsfiddle.net/VMqSy/1/" rel="noreferrer">http://jsfiddle.net/VMqSy/1/</a></strong></p>