SOURCE

/* function Person () {
    return {
        eyes:2,
        head:1
    }
}
function Women (name) {
    this.name = name
}
function Men (name) {
    this.name = name
}
Women.prototype = new Person()
let women = new Women('red')
console.log(women)
Women.prototype.baby = function () {
    console.log('怀孕')
}
women.baby()
Men.prototype = new Person()
let men = new Men('blue')
console.log(men)
men.baby() */

class Person {
    constructor() {
        this.eyes = 2
        this.head = 1
    }
}
class Women extends Person {
    constructor(name,age) {
        super()
        this.name = name
        this.age = age
    }
    setAge (newAge) {
        this.age = newAge
        console.log(`年龄被修改为${this.age}`)
    }
    baby () {
        console.log('执行代码')
    }
}
class Men extends Person {
    constructor(name,age) {
        super()
        this.name = name
        this.age = age
    }
}
let women = new Women('red',18)
console.log(women.age)
women.setAge(99)
console.log(women.age)
women.baby()
let men = new Men('blue',20)
console.log(men)
console 命令行工具 X clear

                    
>
console