What style do you use for creating a "class"?
<p>There are a few ways to get class-like behavior in javascript, the most common seem to be prototype based like this:</p>

<pre><code>function Vector(x, y, x) {
    this.x = x;
    this.y = y;
    this.z = z;
    return this;
}

Vector.prototype.length = function () { return Math.sqrt(this.x * this.x ... ); }
</code></pre>

<p>and closure based approaches similar to</p>

<pre><code>function Vector(x, y, z) {
    this.length = function() { return Math.sqrt(x * x + ...); }
}
</code></pre>

<p>For various reasons the latter is faster, but I've seen (and I frequently do write) the prototype version and was curious as to what other people do.</p>
