title: Trying to understand the difference between prototype and constructor in JavaScript
body: <p>I'm new to JavaScript and trying to understand this concept. I have read many articles regarding prototypes and constructors but wherever I go I'm left with confusion.</p>
  <p>The confusion arises when people talk about constructors and prototypes simultaneously.</p>
  <p>In the following example</p>
  <pre><code>var employee = function Emp(name) {
      this.name = name;
  }
  var jack = new employee(&quot;Jack Dwain&quot;);
  
  employee.constructor // gives Function()
  
  employee.prototype // gives Emp {}
  
  employee.prototype.constructor // gives Emp(name)
  
  jack.constructor // gives Emp(name)
  
  jack.prototype // gives undefined
  </code></pre>
  <ol>
  <li><p>prototype is a way that JS achieves inheritance, since <code>Emp(name)</code> is the base function prototype is referenced to the same function itself. Is that what happened?</p>
  </li>
  <li><p>In what way do <code>employee.constructor</code> and <code>employee.prototype.constructor</code> differ?</p>
  </li>
  <li><p>Why was <code>jack.prototype</code> <code>undefined</code>? i.e. If it is inheriting from the function <code>Emp(name)</code> why didn't it reference that function?</p>
  </li>
  <li><p>How can I clearly predict (without typing in the console) what the prototype or the constructor or the prototype.constructor ......yields?</p>
  </li>
  </ol>