title: What is the advantage of using Prototype in Javascript?
body: <p>I read crockford's page on private members <a href="http://javascript.crockford.com/private.html" rel="nofollow">http://javascript.crockford.com/private.html</a> in Javascript and got a question which maybe somewhat related. Why should a developer use Prototype?</p>
  
  <p>For example,</p>
  
  <p>For example, I can do this</p>
  
  <pre><code>var Foo = new Object();
  Foo.bar = function() { alert('Its a bar'); };
  var x = Foo;
  x.bar();
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>var Foo = function(){};
  Foo.prototype.bar = function(){alert('Its a bar');};
  var x = new Foo();
  x.bar();
  </code></pre>
  
  <p>Both of these implementations do the same thing. How is one different from the other? Does this affect inheritance in any way?</p>