title: Javascript prototype operator performance: saves memory, but is it faster?
body: <p>I read <a href="http://www.crockford.com/javascript/private.html" rel="noreferrer">here (Douglas Crockford)</a> using prototype operator to add methods to Javascript classes <strong>saves also memory</strong>.</p>
  
  <p>Then I read in <a href="http://ejohn.org/blog/simple-class-instantiation/#postcomment" rel="noreferrer">this John Resig's article</a> <em>"Instantiating a function with a bunch of prototype properties is <strong>very, very, fast</strong>"</em>, but is he talking about using prototype in the standard way, or is he talking about his specific example in his article?</p>
  
  <p>For example, is creating this object:</p>
  
  <pre><code>function Class1()
  {
     this.showMsg = function(string) { alert(string); }
  }
  var c = new Class1();
  c.showMsg();
  </code></pre>
  
  <p><strong>slower than</strong> creating this object, then?</p>
  
  <pre><code>function Class1() {}
  Class1.prototype.showMsg = function(string) { alert(string); }
  var c = new Class1();
  c.showMsg();
  </code></pre>
  
  <p>P.S. </p>
  
  <p>I know prototype is used to create inheritance and singleton object etc. But this question does not have anyhting to do with these subjects.</p>
  
  <hr>
  
  <p>EDIT: to whom it might be interested also in <strong>performance comparison between a JS object and a JS static objet</strong> can read <a href="https://stackoverflow.com/questions/3493252/javascript-prototype-operator-performance-saves-memory-but-is-it-faster/4041582#4041582">this answer below</a>. <strong>Static object are definitely faster</strong>, obviously they can be usued only when you don't need more than one instance of the object.</p>