SOURCE

// /** 原型链继承 */
// function Person(){
//     this.name ='小李'
//     this.eats =['apple']
//     this.getName = function(){
//         console.log(this.eats)
//     }
// }
// Person.prototype.get =function(){
//     console.log(this.name)
// }

// function Student(){
  
// }

// Student.prototype = new Person()


// let stu = new Student()

// stu.get()

// stu.getName()

// stu.eats.push('banana')

// let stu2 = new Student()

// stu2.getName()



// /** 构造函数继承 */
// function Person(){
//     this.name ='小李'
//     this.eats =['apple']
//     this.getName = function(){
//         console.log(this.eats)
//     }
// }
// Person.prototype.get =function(){
//     console.log(this.name)
// }

// function Student(){
  
// }

// function Student(){
//     Person.call(this)
// }




// let stu = new Student()

// stu.getName()

// stu.get()







// /** 组合继承 */
// function Person(){
//     this.name ='小李'
//     this.eats =['apple']
//     this.getName = function(){
//         console.log(this.eats)
//     }
// }
// Person.prototype.get =function(){
//     console.log(this.name)
// }
// function Student(){
//     Person.call(this)
// }


// Student.prototype = new Person()


// let stu = new Student()

// stu.get()

// stu.eats.push('banana')


// stu.getName()

// let stu2 = new Student()

// console.log(stu2)

// stu2.getName()



/** 寄生组合继承 */
function Person(){
    this.name ='小李'
    this.eats =['apple']
    this.getName = function(){
        console.log(this.eats)
    }
}
Person.prototype.get =function(){
    console.log(this.name)
}
function Student(){
    Person.call(this)
}

function Fn(){

}

Fn.prototype = Person.prototype

Student.prototype = new Fn()


let stu = new Student()

stu.get()

stu.eats.push('banana')


stu.getName()

let stu2 = new Student()

console.log(stu2)

stu2.getName()
console 命令行工具 X clear

                    
>
console