面向对象中的继承
封装
低耦合,高内聚
多态
重载&重写
重载

其实这是后台的知识,这么做的原因是:涉及到服务器的承压能力。减轻并发数


重写
子类重写父类中的方法
怎么理解面向对象?

一切皆对象……学院派的答法,尽量不要。
- 原型继承

手动加上constructor,保证原型重定向的完整性

本质概念
原型继承:
改变原型链的指向, 让子类的原型链上出现父类的原型,让子类的原型指向父类的某个实例。

特点
- 是查找型继承,不是拷贝继承
- 不希望影响到其他实例
3.我们希望的是,私有的变为私有的,公有的变为公有的



function A(x){
this.x=x;
}
A.prototype.getX=function(){
console.log(this.x);
}
// 原型继承
B.prototype=new A(100)
B.prototype.constructor=B;
function B(y){
this.y=y;
}
B.prototype.getY=function(){
console.log(this.y);
}
- CALL继承和寄生组合继承
子类继承了父类的私有属性,也继承到了子类的私有属性上

- 寄生组合继承

比较推荐的方式
es6之前,相对来说比较完整的方式



Object.create
扩展一下 Object.create
Object.create(proto) 创建一个空对象,让其__proto__指向proto


function A(x){
// console.dir(this);
this.x=x;
}
A.prototype.getX=function(){
console.log(this.x);
}
B.prototype=Object.create(A.prototype);
B.prototype.constructor=B;
function B(x,y){
A.call(this,x)
this.y=y;
}
B.prototype.getY=function(){
console.log(this.y);
}
let b=new B(100,200)
console.dir(b);
// console.dir(Object.create(A.prototype))
- ES6的继承

es6 extends

应用



![[每周一更]-(第23期):Docker 逻辑图及常用命令汇总](https://img-blog.csdnimg.cn/cfca07a8703b4fddb9bc8e6618c2d7dd.png#pic_center)












![[附源码]计算机毕业设计基于SpringBoot的校园报修平台](https://img-blog.csdnimg.cn/4db374525d9f4ba593911464638dc7e7.png)


![[附源码]Python计算机毕业设计Django人员信息管理](https://img-blog.csdnimg.cn/e965403684be41da973c2f2958a79c77.png)
