function fn1(name,dress){ //fn1.prototype.__proto__:Object.prototype
this.name=name,
this.dress=dress
}
fn2.prototype=new fn1("南北","成都")//fn2.prototype.__proto__:fn1.prototype
function fn2(age,post){
this.age=age,
this.post=post
}
fn3.prototype=new fn2(18,"teacher");//fn3.prototype.__proto__:fn2.prototype
function fn3(habbit,edu){
this.habbit=habbit,
this.edu=edu
}
var sy=new fn3("listen to music","成都理工大学")//sy.__proto__:fn3.prototype
console.log(sy.name);//南北
console.log(sy.__proto__==fn3.prototype);//true
console.log(fn3.prototype.__proto__==fn2.prototype);//true
JS当中构造原型链
最新推荐文章于 2021-09-19 20:54:27 发布