模拟继承的三种方式:
1.call()
function Person(name, age) {
this.name =
name;
this.age =
age;
this.eat =
function(name) {
alert(this.name + "正在吃饭"
);
}
}
function Student(sno, name, age) {
Person.call(this, name, age);
this.sno =
sno;
this.study =
function() {
alert("学号为"+
this.sno+"的学生,姓名叫做"+
this.name+",正在努力学习,年龄为"+
this.age);
}
}
var stu =
new Student(1,'wang',23
);
stu.eat();
stu.study();
2.apply()
3.原型链继承prototype
转载于:https://www.cnblogs.com/justlive-tears/p/9393605.html
相关资源:瑞星杀毒软件V17 v25.00.07.30官方版