//call继承主要是继承构造函数中的属性
function Person(age, sex) {
this.age = age;
this.sex = sex;
}
Person.prototype.Sleep = function () {
console.log("睡觉");
}
Person.prototype.eat = function () {
console.log("吃饭");
}
function Student(score,age,sex) {
this.score = score;
Person.call(this,age,sex)
}
Student.prototype.Play=function(){
console.log("别问,就是打球");
}
let stu1=new Student(120,18,"男");
console.log(stu1.age+"\t"+stu1.sex+"\t"+stu1.score);
stu1.Play();
// stu1.eat();//报错
相关文章
- 11-14bootstrapValidator Maximum call stack size exceeded
- 11-14call、apply、bind的用法
- 11-14call-apply-bind区别
- 11-14__init__、__new__、__call__ 方法
- 11-14bind,apply,call使用和区别
- 11-14call bind applay 详解
- 11-14js call
- 11-14ArcEngine10:ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS components.
- 11-14理解Array.prototype.slice.call(arguments)
- 11-14浅谈[].slice.call(arguments, 1)