apstrakt: Objektübernahme in Array

Beitrag lesen

Hallo,

Hallo Christian,

Warum nicht direkt so???

function menustruc(name, top, left) {
this.name = name;
this.position = "absolute";
this.zindex  = "2";
this.top  = top;
this.left  = left;
this.sub  = new Array();
}

Nee, das andere schaut übersichtlicher und eleganter aus ;) *wirklich*

wenn mich nicht alles täuscht, kann man auch mehrere konstruktoren definieren. du könntest also sowohl einen allgemeinen konstruktor wie

function menustruc(name, position, zindex, top, left, sub) {
this.name = name;
this.position = position;
this.zindex  = zindex;
this.top  = top;
this.left  = left;
this.sub  = sub;
}

und einen default-konstruktur (ohne parameter, so wie du es programmiert hast) bereitstellen.

gruß,
a.