编辑代码

function Animal (name) {
    this.name = name
}

Animal.prototype.run = function() {
    console.log("Animal runs")
}

Animal.eat = function() {
    console.log('eat')
}

function Dog (name, age) {
    Animal.call(this, name)
    this.age = age
}
// Dog.prototype = new Animal()
Dog.prototype = Object.create(Animal.prototype)
Dog.prototype.constructor = Dog

var dog = new Dog('tom')
console.log(dog.__proto__ === Dog.prototype)
dog.run()
console.log(Object.getOwnPropertyNames(dog.__proto__))
console.log(Object.getOwnPropertyDescriptor(dog.__proto__, 'name'))

for (key in Dog.prototype) {
    if (Dog.prototype.hasOwnProperty(key)) {
        console.log(key)
    }
}

class People {
    constructor(name) {
        this.name = name
    }

    say () {
        console.log("say something")
    }

    static walk () {
        console.log("go somewhere")
    }
}

class Student extends People {
    constructor(name, age) {
        super(name)
        this.age = age
    }
}

var p = new People("Jerry")
var s = new Student("Tom", 3)
// s.say()
// for (key in s) {
    // if (People.prototype.hasOwnProperty(key)) {
        // console.log(key)
    // }
// }

console.log(Object.getOwnPropertyDescriptor(s.__proto__, 'age'))