这段代码第二个为什么输出false?

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


阅读 1.2k
1 个回答

如下:

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
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进