A cópia do código é a seguinte:
// Use a representação do objeto para realizar a herança do JS
função a (cor) {
this.acolor = cor;
this.ASHOWCOLOR = function () {
document.writeln ("acolor:" + this.acolor);
}
}
Função B (cor, nome) {
// Atribua o NewMethod a A e chama o construtor de A
this.newMethod = a;
this.NewMethod (cor);
// exclua a referência a A, para que ele não possa ser chamado no futuro
exclua este.newMethod;
this.bname = nome;
this.bshowname = function () {
document.writeln ("bname:" + this.bname);
}
}
var obja = novo a ("vermelho");
obja.ASHOWCOLOR ();
Document.Writeln ("----------------------------------------------------------------------------------------------------------------------------
var objb = new B ("Black", "Demo");
objb.ASHOWCOLOR ();
objb.bshowName ();
Document.Writeln ("----------------------------------------------------------------------------------------------------------------------------