I don't know exactly what is happening when goog.inherit is called
Check the code of goog.inherits
then. It should look familiar if you know the common Object.create
shim and what it does.
As you can see, it completely overwrites the childCtor.prototype
, not preserving any old properties on it - which can be problematic and indeed trahes the function3
and function4
methods you previously defined on it in your example. So you will need to inherit first, then extend the new prototype object.
If you still want to use an object literal, that is no problem:
company.app.MySubClass = function(param) {
company.app.MyClass.call(this, param);
};
goog.inherits(company.app.MySubClass, company.app.MyClass);
goog.mixin(company.app.MySubClass.prototype, {
function3: function() {
//Do stuff.
},
function4: function() {
//Do more stuff.
}
});