class Person {
constructor(name, age, gender) {
this.name = name
this.age = age
this.gender = gender
}
}
class Student extends Person {
constructor(name, age, gender, school, xlass) {
super(name, age, gender)
this.school = school
this.xlass = xlass
}
}
var s = new Student('jack', 12, 'boy', 'fz1z', 4)
console.log(s.__proto__.__proto__ instanceof Object) // true
console.log(s.__proto__.__proto__.__proto__ === null) // false
回答
如下:
s.__proto__ === Student.prototype // true
s.__proto__.__proto__ === Person.prototype // true
s.__proto__.__proto__.__proto__ === Object.prototype // true
s.__proto__.__proto__.__proto__.__proto__ === null // true
本文地址:H5W3 » 这段代码第二个为什么输出false?