es6继承

复制代码

class father{
constructor(x,y){
this.x=x;
this.y=y;
}
ddd(){}
}
class son extends father{
constructor(x,y,z){
super(x,y);
this.z=z;
}
ggg(){}
}
var r=new son(1,2,3);
console.log(r.__proto__===son.prototype);
console.log(r.__proto__);
console.log(son.prototype);
console.log(father.prototype);
console.log(r instanceof son);
console.log( r instanceof father);
console.log( r.__proto__===son.prototype);//true
console.log(son.__proto__===father);//true
console.log(son.__proto__);//father 类
console.log(son.prototype);//class子类对象

复制代码

可见 r.__proto__===son;

son.protopype==father;

son.__proto__=class son extends father{....}

posted on   偏灬爱  阅读(95)  评论(0编辑  收藏  举报

< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示