
1、实例不是父类的实例,只是子类的实例。
2、能够继承父类的实例属性和方法,不能继承原型属性/方法。
3、函数无法复用,每个子类都有父类实例函数的副本,影响性能。
实例
functionStar(name,age){
this.name=name
this.age=age
this.sayName=function(){
console.log(this.name)
}
}
Star.prototype.sing=function(){
alert(this.name)
}
varldh=newStar('刘德华',28)
varzxy=newStar('张学友',29)原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
















































暂无评论内容