class Person{
constructor(name){
this.name = name
}
}
class Student extends Person {
constructor(name, id) {
super(name)
}
}
console.log(p.__proto__ === Person.prototype)
console.log(s.__proto__ === Student.prototype)
console.log(Student.prototype.__proto__ === Person.prototype)//true
console.log(Student.prototype.constructor === Student)
JS没有类,只有键值对组成的数据
普通对象的__proto__属性指向该实例的构造函数的原型对象,s.__proto__ === Student.prototype
原型对象的__proto__属性指向父构造函数的原型对象,Student.prototype.__proto__ === Person.prototype
class Person的本质是个函数