<script>
function Father(uname,age) {
this.uname=uname,
this.age=age
}
Father.prototyep.monye=function(){
console.log('父亲我有很多mony')
}
Son.prototype=new Father();
Son.prototype.constructor=Son //手动返回构造函数constructor
Son.prototype.school=function(){
console.log('搞学习')
}
function Son(uanme,age){
Father.call(this,uname,age)
}
var father1=new Father('zs',45)
var son1=new Son('ls',15)
console.log(father1)
console.log(son1)
</script>
Javascript 组合继承
最新推荐文章于 2024-06-21 16:41:46 发布