title: Do JavaScript class instances clone functions?
body: <p>If i have the following code:</p>
  
  <pre><code>function myClass(){
      this.type = 1;
      this.ret = function(){
          return this.type;
      }
  }
  
  var ins1 = new myClass,
      ins2 = new myClass,
      ins3 = new myClass;
  
  ins2.type = 2;
  ins3.type = 3;
  
  console.log(ins1.ret() + ' - ' + ins2.ret() + ' - ' + ins3.ret());
  </code></pre>
  
  <p>The output in the console is</p>
  
  <p><code>1 - 2 - 3</code></p>
  
  <p>When the code runs (the <code>console.log()</code> part), is there one method <code>ret()</code> running, or three? If each instance creates a new method, how can I avoid that? If they all do the same exact thing, why have three of them.</p>