title: What is the difference between A.prototype = B.prototype and A.prototype = new B()?
body: <p>I am learning JavaScript and found two ways of assigning prototype.</p>
  
  <p>The first is <code>A.prototype = B.prototype</code> and the second is <code>A.prototype = new B()</code></p>
  
  <p>For example:</p>
  
  <pre><code>function A() {
    console.log("A!")
  }
  
  function B() {
    console.log("B!")
  }
  
  // First case
  A.prototype = B.prototype;
  a = new A();  // a instanceof A,B
  
  // Second case
  A.prototype = new B();
  a = new A();  // a instanceof A,B
  </code></pre>
  
  <ol>
  <li>Is there any difference and which way to prefer?</li>
  <li>Is there any other way to assign prototype?</li>
  </ol>
  
  <p>Update:</p>
  
  <p>As Felix Kling advised there is a third way to assign a prototype:</p>
  
  <pre><code>A.prototype = Object.create(B.prototype);
  </code></pre>