On the inheritance of es5 prototype

questions about es5 inheriting subconstructor prototypes

clipboard.png

Line 5 of the code
I can understand that the prototype of the fourth line of child constructor is Sub.protorype = new Super ()
from the parent constructor new, so here Sub.protorype.constructor = Super is
for true. What is the reason for redirecting the constructor of the prototype of the child constructor to itself?
I find that Sub.protorype.constructor = Sub can also inherit

if this statement is not executed.
Feb.26,2021

can be inherited, but the instance of Sub made a mistake when getting constructor. It is obviously wrong to become Super. This is a side effect. This side effect should be corrected.


constructor just tells you which constructor the instance is initialized with, and does not affect the prototype chain

Sub.protorype.constructor = Sub;

whether the above sentence is written or not, it does not affect the prototype chain, and the following code is always true

.
       Sub.prototype.__proto__.__proto__ === Object.prototype //
       sub1 instanceof Super
       sub1 instanceof Sub //1Sub

in short, the prototype chain depends on _ _ proto__, and constructor is just a pointer attribute for detection

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-1beb36e-31a6d.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-1beb36e-31a6d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?