继承发展史
1、传统模式 – 原型链
继承了过多没用的属性
2、借用构造函数
不能继承借用构造函数的原型;
每次构造函数要多走一个函数。
3、共享原型
Father.prototype.lastName = “GT”;
function Father(){
}
function Son(){
}
Son.prototype = Father.prototype
var son = new Son();
var father = new Father();
继承发展史
1、传统模式 – 原型链
继承了过多没用的属性
2、借用构造函数
不能继承借用构造函数的原型;
每次构造函数要多走一个函数。
3、共享原型
Father.prototype.lastName = “GT”;
function Father(){
}
function Son(){
}
Son.prototype = Father.prototype
var son = new Son();
var father = new Father();