Ye.prototype.name=‘deng’;
function Ye(){
}
var ye=new Ye();
function Father(){
}
// Ye.prototype=Father.prototype; 顺序颠倒了
function F(){
}
var f=new F();
var father=new Father();
function Son(){
}
// Son.prototype=father;
var son=new Son();
//Father.prototype=son;
F.prototype=Ye.prototype;
Father.prototype=f;
########################################################
错误的代码 因为f出生的时候 还没有 prototype 所以 后面赋值 不会生效
Father.prototype.name=‘laodeng’;
function Father(){
}
function Son(){
}
function F(){
}
var f=new F();
F.prototype=Father.prototype;
Son.prototype=f;
###########################################
正确的代码
Father.prototype.name=‘laodeng’;
function Father(){
}
var father=new Father();
function Son(){
}
function F(){
}
F.prototype=Father.prototype;
var f=new F();
Son.prototype=f;
//Son.prototype=father;
var son=new Son();
########################################
函数的封装
Father.prototype.name=‘laodeng’;
function Father(){
}
function Son(){
}
function huan(mu,yuan){
function F(){
}
F.prototype=yuan.prototype;
mu.prototype=new F();
}
// var f=new F();
huan(Son,Father);
var son=new Son();