Does prototype really matter in JavaScript if the class will never be subclassed?
<p>So, in answering another question on this site, I wrote a class for someone to create a BitArray instance in JavaScript.  The code I posted looked like this:</p>

<pre><code>var foo = function(param1) {
    this._member = param1;
    this.getMember = function() { return this._member; };
    this.setMember = function(val) { this._member = val; };
    this.alertMember = function() { alert(this._member); };
    foo.STATIC_CONSTANT = "some value";
}
</code></pre>

<p>One of the comments I received was a rather stern "You should absolutely add the methods to foo.prototype instead of this".  If I take that criticism and apply it to the above, it turns the code into:</p>

<pre><code>var foo = function(param1) {
    this._member = param1;
}
foo.prototype.getMember = function(){ return this._member; };
foo.prototype.setMember = function(val) { this._member = val; };
foo.prototype.alertMember = function() { alert(this._member); };
foo.STATIC_CONSTANT = "some value";
</code></pre>

<p>My question is, what's the difference here between the two approaches assuming foo will never be subclassed?  </p>

<p>To be clear, I'm not advocating writing sloppy code - I credit the commentor with catching me being sloppy - but as I was conceeding to his correctness, it really did make me think - why should I prototype if I'm creating an effectively sealed class? </p>

<p>Is there some performance or functional consequence I'm missing here?  Or when a class won't be subclassed is using the prototype irrelevent?</p>
