[ascoders] Re: super

  • From: Ralf Siegel <ralf@xxxxxxxxxxx>
  • To: ascoders@xxxxxxxxxxxxx
  • Date: Wed, 28 Jan 2004 01:01:52 +0100


mmhh. Und mein Contructor wird nicht wirklich aufgerufen. Ich rufe im
Contructor der Superklasse eine init function auf, die nicht aufgerufen
wird, wenn ich per: super.constructor.apply( super , arguments ); die
SubKlasse ableite.

Ist zwar schon spät, aber der Code funktioniert eigentlich soweit:


-----------------------------------------------------

function A()
{
        trace("A:" + arguments);
        this.init();
}
A.prototype.init = function()
{
        trace("init A");
};
function B()
{
        super.constructor.apply(super, arguments);
        trace("B:" + arguments);
}
B.prototype.__proto__ = A.prototype;
B.prototype.__constructor__ = A;
obj = new B(1, 2, 3, 4, 5);

-----------------------------------------------------

A:1,2,3,4,5
init A
B:1,2,3,4,5

-----------------------------------------------------

Warum schreibst du nicht:

super.constructor.apply(this, arguments);

?

ralf ...


------------------------------------------------------------- Ralf Siegel - Freelance Developer Recommended Listening: Isobell Campell - Amorino (Snowstorm) http://www.isobelcampbell.com -------------------------------------------------------------

------------------------------------------------------
Archiv   : //www.freelists.org/archives/ascoders/
Optionen : //www.freelists.org/list/ascoders
------------------------------------------------------

Other related posts: