Inheritance selfmade or reinventing wheel Background

I like to code JavaScript in a typical style with "classes" and inheritance. My goal was to create an easy way to make inheritance available and keep classes that inherits from others clean. Also I like to use the module pattern and uses its look and feel.

My solution

I hope the code is self-explanatory. I'm using it in all my newer projects and it seems to work fine.

 if(typeof(SimpleJSLib)==='undefined'){
     var SimpleJSLib = {}; // define namespace
 }
 SimpleJSLib.BaseObject = function(){
     // returns an object you wether can inherit from or instantiate it
     var createInheritObject = function(inheritFunctions){
         return {
             // instantiate the current class
             // iterates through all functions which the class inherits from and calls them
             construct : function(){
                 var me = {}, _protected = {};
                 for(var i = 0; i &lt; inheritFunctions.length; i++){
                     me = inheritFunctions[i].call(me, me, _protected);
                     if(typeof(me)==='undefined'){
                         throw 'Inherit function did not return "me"';
                     }
                 }
                 // if a constructor is defined we call them and deliver the arguments this function was called with
                 if(typeof(_protected.construct)!=='undefined'){
                     _protected.construct.call(me, arguments);
                 }
                 return me;
             },
             // clones the pointers to the functions you inherit from
             // and returns another object you can instantiate or inherit from
             inherit : function(inheritFunction){
                 var _inheritFunctions = inheritFunctions.slice(0); // clone
                 _inheritFunctions.push(inheritFunction);
                 return createInheritObject.call(window, _inheritFunctions);
             }
         };
     };

     return {
         // allows you to inherit directly from BaseObject
         inherit : function(inheritFunction){
             // this is the first call of the function, so the the inheritFunctions array just contains one function
             return createInheritObject.call(window, [inheritFunction]);
         }
     }
 }();


Questions

Is there any good argument why I shouldn't use this code snippet?
How about performance? Is there anything I could make better?

Examples

Just a few simple ones.

var MyClass = SimpleJSLib.BaseObject.inherit(function(me, _protected){
    // protected
    _protected.myValue = 'value';
    _protected.doSomething = function(){
        console.log('something')
    };
    // public
    me.getMyValue = function(){
        return _protected.myValue;
    }
    return me;
});
var MySubClass = MyClass.inherit(function(me, _protected){
    me.anotherFunction = function(){
        _protected.doSomething();
    }
    return me;
});
var myClassInstance = MyClass.construct();
console.log(myClassInstance.getMyValue());
var mySubClassInstance = MySubClass.construct();
console.log(mySubClassInstance.anotherFunction());


Using the constructor

var MyClass = SimpleJSLib.BaseObject.inherit(function(me, _protected){
    _protected.valueOne = null;
    _protected.valueTwo = null;
    _protected.construct =  function(parameters){
        _protected.valueOne = parameters[0];
        _protected.valueTwo = parameters[1];
    };
    return me;
});
var myClassInstance = MyClass.construct('valueOne', 'valueTwo');


Singelton

var Singelton = SimpleJSLib.BaseObject.inherit(function(me, _protected){
    return me;
}).construct(); // mention the construct!
From some staring at your code:


Do not declare var in an if block, it gives the wrong impression. I would just declare it on top, something like this:

//Define namespace
var SimpleJSLib;
SimpleJSLib = SimpleJSLib || {}; 


As far as naming, since SimpleJSLib is not a constructor, it should not start with capital S. The name JSLib is not very informative beyond what language it is writen in..
I know that for some _ in _protected means "private", but I agree with Crockford that this convention should be avoided
Now a big one: you broke support for instanceof operator, that's just wrong
Furthermore, you kind of broke support for prototype, you are also not using hasOwnProperty anywhere when you construct objects
And, JS has a perfectly valid constructor, but you decided to have your own construct
Finally, this will be messy once you want to start serializing with JSON


Honestly, read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript and abandon your code. I would not want to maintain code that relies on this.