How can I fix this example so that it works after the first or second subclass?
<p>In this example, I'm trying to create a Class template, then using that to create a base 'class', and so on and so forth.</p>

<p>It all works until I get to NewStudent. I get a type error 'object is not a function'.</p>

<pre><code>var Class = function(options) {
    var newClass = function(options) {
        $.extend(this, options);
    };

    if (options) {
        $.extend(newClass, options);
    }

    newClass.prototype = newClass;
    newClass.prototype.constructor = newClass;
    return newClass;
};

var Person = new Class();
Person.prototype.speak = function() {alert(this.name + ', ' + this.type);}


var Student = new Person({name: 'Student', type: 'Student'});
Student.speak();

var NewStudent = new Student({name: 'NewStudent'});
NewStudent.speak();
</code></pre>

<p>If I change: </p>

<pre><code>var newClass = function(options) {
    $.extend(this, options);
};
</code></pre>

<p>to: </p>

<pre><code>var newClass = function(options) {
    $.extend(this, options);
    return newClass;
};
</code></pre>

<p>It it executes the speak call, but the name is blank, and the type is unidentified.</p>

<p>I'm using jquery for the $.extend method.</p>

<p>How can I improve this so it works? I'm trying to do something similar to the way Mootools does their Class, except I want to create my own barebone version. </p>
