Js inheritance, why can't ClassB.prototype.__proto__ = ClassA.prototype be used?

paste the code first

function ClassA(name) {
    this.name = name
}

ClassA.prototype.sayName = function () {
    // 
}

function ClassB(name, age) {
    ClassA.call(this, name)
    this.age = age
}

// 
ClassB.prototype.__proto__ = ClassA.prototype

ClassB.prototype.sayAge = function () {
    // 
}

let instance = new ClassB("", 11)

Why can"t ClassB.prototype.__proto__ = ClassA.prototype be used in implementation inheritance?

Mar.03,2021

_ _ proto__ is a property added by the browser to allow you to access the prototype of the object. It's not standard. It can only be used in some browsers. You can modify it like this:

function ClassA(name) {
      this.name = name
    }

    ClassA.prototype.sayName = function () {
      alert(this.name)
    }

    function ClassB(name, age) {
      ClassA.call(this, name)
      this.age = age
    }

    ClassB.prototype.constructor.prototype = ClassA.prototype // constructor.prototype 

    ClassB.prototype.sayAge = function () {
      alert(this.age)
    }

    let instance = new ClassB('', 11)
    instance.sayName(); //
    instance.sayAge();  //11

Object.prototype.__proto__ , it turns out that can be used

function ClassA(name) {
    this.name = name
}

ClassA.prototype.sayName = function () {
    // 
}

function ClassB(name, age) {
    ClassA.call(this, name)
    this.age = age
}

// ClassB.prototype.__proto__ = ClassA.prototype
ClassB.prototype = Object.create(ClassA.prototype)

ClassB.prototype.sayAge = function () {
    // 
}

let instance = new ClassB('', 11)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37fda-2c0d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37fda-2c0d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?