title: Javascript: How to create a new instance of the prototype object?
body: <p>The prototype is an object that is inherited? by all instances of the object, like child in my following example. </p>
  
  <p>It has to be an instance of the parent, else parent's prototype will not get inherited? </p>
  
  <p>In this case, the goal is to create a separate array, which is inherited from parent, for each instance of child. </p>
  
  <p>I am unsure how to achieve that exactly. I know of <a href="https://github.com/amatiasq/jsbase/blob/master/src/extend.js" rel="nofollow">extend</a>.</p>
  
  <p>Is the extend method simply copying prototypes over to a new object and applying the new methods onto it as well? </p>
  
  <p>My code example + <a href="http://jsfiddle.net/MUWGN/" rel="nofollow">jsfiddle</a>: </p>
  
  <pre><code>function parent(){
  }
  
  parent.prototype.arr = []; 
  parent.prototype.add = function(item){
      this.arr.push(item);
  }
  parent.prototype.show = function(){
  
      for(var i = 0; i &lt; this.arr.length; ++i){
          $('body').append(this.arr[i]);
      }
  }
  
  
  function child(childname){
      this.add(childname); 
  }
  child.prototype = new parent();
  
  
  var child1 = new child('child1');
  var child2 = new child('child2');
  
  child2.show();//this should only show child2? 
  </code></pre>