title: Understanding Javascript constructors: custom create method
body: <p>I'm trying to get a better understanding of OOP in Javascript. Can someone please explain how the create method is being used in the example below and an alternative? I've looked it up on the web and reviewed several posts on SO and still don't have a solid grasp of what's happening in the code below. I've provided comments to illustrate my understanding. Please correct me where I'm wrong.</p>
  
  <p>This example is used to override a method from a base class:</p>
  
  <pre><code>// Defines an Employee Class
  function Employee() {}
  
  // Adds a PayEmployee method to Employee
  Employee.prototype.PayEmployee = function() {
      alert('Hi there!');
  }
  
  // Defines a Consultant Class and
  // Invokes the Employee Class and assigns Consultant to 'this' -- not sure and not sure why
  // I believe this is a way to inherit from Employee?
  function Consultant() {
      Employee.call(this);
  }
  
  // Assigns the Consultant Class its own Constructor for future use -- not sure
  Consultant.prototype.constructor = Consultant.create;
  
  // Overrides the PayEmployee method for future use of Consultant Class
  Consultant.prototype.PayEmployee = function() {
      alert('Pay Consultant');
  }
  </code></pre>