以下是您的代码。如何在第二个构造函数中调用一个构造函数
function ClassA() {
this.sayA = function() {
console.log( "A" );
}
this.sayC = function() {
console.log( "AC" );
}
}
function ClassB () {
this.sayB = function() {
console.log( "B" );
}
this.sayC = function() {
console.log( "BC" );
}
}
var myB = new ClassB();
输出:
myB.sayB();
myB.sayC(); //should print both AC & BC
myB.sayA(); //should print A.