原理:
复制被继承实例、重写继承构造函数原型!
代码理解
// 父类
function SuperType(){
this.memberList = ['a','b','c']
}
// 子类
function SubType(){
this.cur = 'a'
}
SubType.prototype = new SuperType();
let A1 = new SubType()
let A2 = new SubType()
A1.memberList.push(111)
console.log(A2)
缺点
- 所有实例都是引用原型对象、数据篡改会影响所有实例!