1. 原形链
function Father() {
this.fatherName = "licus";
}
function Children() {
this.chidrenName = "king";
}
Children.prototype = new Father();
2.借用构造函数
function Father() {
this.fatherName = "licus";
}
function Children() {
Father.call(this);
}
3.组合继承
function Father(name){
this.name = name;
}
Father.prototype.sayName = function(){
console.log(this.name);
}
function Children(name, age) {
Father.call(this, name);
this.age = age;
}
Children.prototype = new Father();
4.原型式继承
function object (o) {
function Instance() {}
Instance.prototype = o;
return new Instance();
}
5.寄生式继承
function object (o) {
function Instance() {}
Instance.prototype = o;
return new Instance();
}
function createInstance(o) {
var clone = object(o);
clone.Name = "lucis"
return clone;
}
6.寄生组合式继承
function object(o){
function F() {}
F.prototype = o;
return new F();
}
function inherit Prototype(Children, Father){
var prototype = (Father.prototype);
prototype.constructor = Children;
Children.prototype = prototype;
}