function ClassA (sColor) {
  this.color = sColor;
  this.sayColor = function () {
  alert(this.color);
  }
}

function ClassB (sColor,sName) {
  this.newMethod = ClassA;
  this.newMethod (sColor);
  delete this.newMethod;

  this.name = sName;
  this.sayName = function () {
  alert(this.name);
  }
}

var objA = new ClassA("red");
var objB = new ClassB("blue","Nicholas");
objA.sayColor();
objB.sayColor();
objB.sayName();

//red

//blue

//Nicholas

相关文章:

  • 2022-12-23
  • 2021-09-15
  • 2022-02-18
  • 2022-12-23
  • 2022-01-17
  • 2021-08-06
  • 2021-10-27
  • 2022-12-23
猜你喜欢
  • 2022-01-03
  • 2021-12-09
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案