What are advantages to adding methods to a class vs adding methods to a class's prototype?
<p>When I write a javascript class, its usually like this:</p>

<pre><code>var myClass = function(prop1, prop2) {
    this.prop1 = prop1;
    this.prop2 = prop2;

    this.method1 = function() {//blah}
    this.method2 = function() {//blahblah}
}
</code></pre>

<p>But most books/tutorials I've read describe writing classes like this:</p>

<pre><code>var myClass = function(prop1, prop2) {
    this.prop1 = prop1;
    this.prop2 = prop2;
}
myClass.prototype.method1 = function() {//blah}
myClass.prototype.method2 = function() {//blahblah}
</code></pre>

<p>What is the difference between these two approaches? Is one better than the other?</p>
