释放双眼,带上耳机,听听看~!
//借用构造函数的 组合继承.
//声明了一个构造函数Person
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype = {
constructor: Person,
sayHi: function () {
console.log('你好,我的名字是' + this.name);
}
}
//声明一个学生构造函数Student
function Student(name, age, score) {
//借用Person构造函数继承
Person.call(this, name, age);
this.score = score;
}
//替换原型继承.
Student.prototype = new Person();
Student.prototype.sayHello = function () {
console.log('哈哈哈.学生的sayHello');
}
//实例化学生对象
let s1 = new Student('张三', 19, 100);
console.log(s1);
s1.sayHi();
s1.sayHello();
//实例化人对象
let p1 = new Person('李四', 19);
console.log(p1);
p1.sayHi();
内容投诉









![[前端开发] MUI框架详解-全面讲解MUI框架使用](https://www.bloglab.cn/wp-content/uploads/thumb/2018/12/fill_w372_h231_g0_mark_80e5f34e03334950b3a4cb73bf4262dd.jpg)


![[MySQL] MySQL面试指南](https://www.bloglab.cn/wp-content/uploads/2018/12/1532f1414c3e23.jpg)

