I don't know much about inheritance in javascript, a little searching made it look cumbersome to me and had little control compared to inheritance in other languages. the real reason I wanted to try inheritance in javascript was to use object composition so I could have one object "transparently" control other diverse objects. but then I first needed to use inheritance and the methods I saw to achieve that confused me and didn't impress me that much. so I tried my own hand at it and I'm curious what others think on how well it will perform. anyway here goes...

I wanted to emulate public, private and protected variables and so the way I decided to accomplish that is taking advantage of closures and scopes:
Code:
function classfactory(_class){

//protected vars go here
var provar = "I'm accessible to all classes but only IN these classes!";
var classes = {};

//the classes are defined as a "contructor" function and return all public functions and variables in an object.
classes.superclass = function(init){
	//private vars go here
	var privars="ONLY the superclass has access to me!";

	provar += "\n and then superclass changed me!";

	return {
		//public var go here!
		pubvar:"EVERYONE can see and use me!",
		print:function(){return privars +"\n but then superclass gave me to everyone!"}
	};

};

//subclass "inherits" from superclass
classes.subclass = function(init){
	var sup = classes.superclass(init);
	
	//in the subclass I overload the print function. however, you'll need to
	//ghost the function into a temp varible if you intend to call the super
	//version otherwise the function will infinitely call it recursively.
	//closures will prevent access to the ghostvariable outside the object
	var ghostsup=sup.print;
	sup.print=function(){
		return ghostsup() + "\n and then subclass overloaded me!\n\n" + provar + "\n and subclass revealed me!"};

	return sup;
	};

        //this is how the classfactory controls the inheritance and makes 
        //sure the right class is invoked and returned. if someone want the 
        //superclass they can't access the subclass in the same object.
	return classes[_class];
};
classfactory is a "factory" class that helps emulate inheritance and encapsulates the class family. you pass in the type of class you want and it handles the rest and noone else worries about it. The super class and all of the classes that will inherit from it are all defined INSIDE this factory. doing so allows the use of protected variables used via placing them in classfactory's scope. this way all classes in the class have access to it but nobody outside the class do. now all the classes are also considered protected so the user can't have direct access to any of them, and the classfactory makes sure they only get one class.

now what does my running code look like?
Code:
var myclass = classfactory("superclass")("i'm constructor args for super");
alert(myclass.print());

/*prints:
ONLY the superclass has access to me!
 but then superclass gave me to everyone!
*/

myclass = classfactory("subclass")("i'm constructor args for sub");
alert(myclass.print());

/*prints:
ONLY the superclass has access to me!
 but then superclass gave me to everyone!
 and then subclass overloaded me!

 I'm accessible to all classes but only IN these classes!
  and then superclass changed me!
  and subclass revealed me!
*/
alert(myclass.pubvar);
/*prints:
EVERYONE can see and use me!
*/
now the "myclass.print();" is completely identical to our eyes but behind the scenes they can do completely different things. thus I can use this like an adapter to delegate a similar command to numerous different objects and so on and so forth. hopfully others find this inheritance method easy to understand, flexible, and powerful.

The only possible inflexibility I see is that all the sub-classes must be defined in the same area, I'm unsure how badly a trade-off that may be. unless someone has some idea to allow such while still being easy to follow and control.

another downside is theres no in-built restriction preventing the superclass from directly accessing the any subclass. now someone might beable to do some cool things because of that, but at the moment I think its dangerous (possible infinite recursions) and thus the best defense is common coding sense.

thoughts? suggestions? critiques?

WAIT! actually I just got this idea to prevent super access to subclasses as such (haven't tested yet):
Code:
classes.superclass = function(){
//code chunks here
};

if(_class ==="superclass")return class.superclass;

classes.subclass = function(){
//code chunks here
};
by returning before any subclasses are defined helps enforce that. and thinking a bit more...I could also create another wrapper class around classfactory so that people could define a subclass in insert it as an argument via an "add_subclass=function(){};". I'll work on this some more but I'll go ahead and post what I got now and see what people think.