SOURCE

// 原型链继承
function SuperType() { 
 this.propertys = ['blue']; 
} 
function SubType() {} 
// 继承 SuperType 
SubType.prototype = new SuperType();
let instance = new SubType(); 
instance.propertys.push('red')
console.log(instance.propertys, 'color'); 
let instancesda = new SubType(); 
console.log(instancesda.propertys, 'color'); 

function SuperType1() { 
 this.propertys = 1 
} 
function SubType1() {} 
// 继承 SuperType 
SubType1.prototype = new SuperType1();
let instance1 = new SubType1(); 
instance1.propertys = 2
console.log(instance1.propertys, 'num'); 
let instance2 = new SubType1(); 
console.log(instance2.propertys, 'num'); 
// function SuperType() { 
//  this.colors = ["red", "blue", "green"]; 
// } 
// function SubType() {} 
// // 继承 SuperType 
// SubType.prototype = new SuperType(); 
// let instance = new SubType(); 
// instance.colors.push("black"); 
// console.log(instance.colors); // "red,blue,green,black" 
// let instances= new SubType(); 
// console.log(instances.colors); // "red,blue,green,black" 

// 盗用构造函数继承 
// function gouzao (name) {
//     this.colors = ['red']
//     this.colors.push(name)
// }
// function gouzaojicheng () {
//     gouzao.call(this, 'blue')
// }

// let instance1 = new gouzaojicheng();
// instance1.colors.push('yellow')
// // console.log(instance1); 

// // 组合继承


// function zuhe (name) {
//     this.color = ['red']
//     this.color.push(name)
// }
// zuhe.prototype.getColors = function () {
//     return this.color
// }

// function jicheng (name) {
//     zuhe.call(this, name)
// }

// jicheng.prototype = new zuhe()

// let instance2 = new jicheng('blue')
// instance2.color.push('yelow')
// console.log(instance2.getColors(), 1)

// let instance3 = new jicheng('black')
// instance3.color.push('green')
// console.log(instance3.getColors(), 2)
console 命令行工具 X clear

                    
>
console