function B(color, name) {
//将newMethod赋值A,调用A的构造函数
this.newMethod = A;
this.newMethod(color);
//然后删除对A的引用,这样以后不能调用他
delete this.newMethod;
this.Bname = name;
this.BshowName = function() {
document.writeln("Bname: " + this.Bname);
}
}
var objA = new A("red");
objA.AshowColor();
document.writeln("----------------");
var objB = new B("black", "demo");
objB.AshowColor();
objB.BshowName();
document.writeln("----------------");
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com