Die Codekopie lautet wie folgt:
// Die Anrufmethode zum Implementieren von JS -Vererbung verwenden
Funktion a (Farbe) {
this.acolor = color;
this.ashowcolor = function () {
document.writeeln ("acolor:" + this.acolor);
}
}
Funktion B (Farbe, Name) {
A.call (this, color);
this.bname = name;
this.bshowname = function () {
document.WriteLn ("Bname:" + this.bname);
}
}
var obja = new a ("rot");
obja.ashowcolor ();
document.writeln ("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var objb = new B ("schwarz", "Demo");
objb.ashowcolor ();
objb.bshowname ();
document.writeln ("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------