一、基于prototype原型

function Person(name){
    this.name = name;
}
Person.prototype.eat="food";
function Student(name,eat){
    Person.apply(this, arguments);
}
Student.prototype = new Person();
var s1 = new Student("王大", "food");
console.log(s1.name);
console.log(s1.eat);
View Code

相关文章:

  • 2021-12-20
  • 2021-12-05
  • 2021-12-06
猜你喜欢
  • 2021-11-13
  • 2021-11-11
  • 2021-11-16
相关资源
相似解决方案