/UPDATE: newest version, provides super property, does not invoke parent constructor. can call super methods with this.super.method(args), or constructor with this.super.constructor.call(this);

var SubClass = function(sup, sub){
    var proto = function(){};
    proto.prototype = sup.prototype;
    sub.prototype = new proto();
    sub.prototype.super = sup.prototype;
    sub.prototype.constructor = sub;    
    return sub;

/END UPDATE. From here down consider legacy

There are several approaches to forcing JavaScript inheritance to behave like other, more natively-OOP languages, from Dean Edwards Base.js, to John Resig’s take on it, to the approaches used by Prototype.js and MooTools (my personal recommendation). This is something jQuery doesn’t even attempt (although some less impressive plugins are available), which is one reason I don’t understand how anyone can rationally compare jQuery to MooTools.

Some of the approaches above (including Dean Edwards’ approach, and the framework/toolkits) also address other issues, such as initializing non-primitive members for each instance (which is very handy), or binding scope (ala MooTools Binds implementation). As always, I’m a big fan of the upshot.

Here’s my take:

Function.prototype.extend = function(construct){
	construct.prototype = new this();
	construct.prototype.super = construct.prototype.constructor;
	construct.prototype.constructor = construct;
	return construct;

This allows method overriding, prototype inheritance, and preserves prototypal chain (instanceof).

From a subclass, you can access a superclass by referencing super or super.prototype.

The one big thing I don’t like is that, during the instantiation of the superclass to serve as the proto, the superclass is actually invoked (so that if a superclass actually “does” something, it’ll happen during the act of extension. This failure seems to be common to all approaches, though, and I don’t see any way around it without a iterative copy of members from one prototype to the other (which may, after all, turn out to be the best way to go).

Anyway, some POC:

var sup = function(a){
	this.a = a;
sup.prototype.a = null;
sup.prototype.m = function(){
	console.log('sup calling m()');

var sub = sup.extend(function(b){
   this.b = b;
   this.super.call(this, 'a');
sub.prototype.b = null;
sub.prototype.m = function(){
	console.log('sub calling m()');

var s = new sub('b');

console.log(s.a + "\n" + s.b);

console.log(s instanceof sup);  // true
console.log(s instanceof sub);  // true
console.log(s instanceof Array);  // false

And for those who don’t like to pollute the Function namespace, here’s the same thing procedurally:

var SubClass = function(sup, sub){
	sub.prototype = new sup();
	sub.prototype.super = sub.prototype.constructor;
	sub.prototype.constructor = sub;
	return sub;

(per Mat’s comment about clarifying default prototype member values, I’m including this link to his comments and my reply. Thanks Mat!)