Hi,

> Okay, thanks for the help.  I was just trying to figure out how to do
> inheritence in javascript and instead embedded objects inside other
> objects.  :)

Ah, what you are looking for is this:

function super() { /*...*/ };
super.prototype = {
        varA: 'a',
        varB: 'b'
}
function sub() { /*...*/ };
sub.prototype = new super(); // this is equivalent to inheritance

// we can not simply assign an object to prototype now, because that would 
// overwrite the existing prototype. Use jQuery.extend(sub.prototype,{...}); 
// wherever you have jQuery available.
sub.prototype['var1'] = 1;
sub.prototype['var2'] = 2;
sub.prototype['method1'] = function() {
        alert(this.varA); // yes, now we have this.varA
};

(new sub()).method1(); // will alert 'a'.

Christof

Reply via email to