You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//父类函数
function Parent(name){
this.name = name;
this.sayHello = function(){
console.log("Parent Name : %s",this.name);
}
}
//子类函数
function Child(name,age){
this.tempMethod = Parent;
this.tempMethod(name);
this.age = age;
this.sayChild = function(){
console.log("Child Name:%s,Age:%d",this.name,this.age);
}
}
//测试继承
var p = new Parent("Kvkens");
p.sayHello();
var c = new Child("Kvkens",29);
c.sayChild();
1、 原型继承方式
2、 构造函数方式
3、 call、apply 方式
(完)
The text was updated successfully, but these errors were encountered: