You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of opening this issue, line 1183 baffles my mind. Why would Node.js use Object.setPrototypeOf to set the prototypes of the classes/objects? I have heard from MDN that Object.setPrototypeOf is slower and less efficient than if one had just done this instead:
its actually setting the prototype of the prototype of the ctor, not the prototype of the ctor. the other way to do that would be ctor.prototype.__proto__ = Object.create(superCtor.prototype) and Object.setPrototypeOf is just a better way of doing that. either way its replacing the prototype which means the engine has to reoptimise everything.
If it's not too much to ask, why does one have to set the prototype of the prototype of the inheriting object? I'm still learning the ropes of JavaScript, so I'd love to learn as much as I can.
Attached below is the permalink of the code for the
inherits
method of theutil
module.node/lib/util.js
Lines 1170 to 1184 in 39f2096
As of opening this issue, line 1183 baffles my mind. Why would Node.js use
Object.setPrototypeOf
to set the prototypes of the classes/objects? I have heard from MDN thatObject.setPrototypeOf
is slower and less efficient than if one had just done this instead:Although the performance change is insignificant, I still believe that this proposal must be made. Thanks!
The text was updated successfully, but these errors were encountered: