<script>
// 创建一个构造函数
function Person() {
this.eyes = 2,
this.head = 1
}
//1.女人的构造函数想继承Person
function Woman() {
}
// 子类的原型=new 父类
Woman.prototype = new Person() //{eyes:2,head:1}
//指回原来的构造函数
Woman.prototype.constructor = Woman
// 给女人添加一个方法 生孩子
Woman.prototype.baby = function () {
console.log('宝贝');
}
const red = new Woman()
console.log(red);
//2.男人继承
function Man() {
}
Man.prototype = new Person()
//指回原来的构造函数
Man.prototype.constructor = Man
const ming = new Man()
console.log(ming);
</script>