Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heavy use of deprecated __proto__ #1967

Closed
inca opened this issue Mar 11, 2014 · 5 comments
Closed

Heavy use of deprecated __proto__ #1967

inca opened this issue Mar 11, 2014 · 5 comments

Comments

@inca
Copy link

inca commented Mar 11, 2014

Don't know if this came up before, but I noticed heavy use of __proto__ throughout Express codebase, which is deprecated and seems to be heavily discouraged by MDN.

Now, since Express 4 is a fresh start, I was wondering if these fragments could be revisited, too? Frankly, I don't know if this even possible, or is there any good reason to stick with __proto__, so any explanations on this one would be very much appreciated.

@jonathanong
Copy link
Member

reopen this issue when we can do Object.setPrototypeOf() in all supported versions of node. there's not much we can do about it now.

@rlidwka
Copy link
Member

rlidwka commented Mar 11, 2014

reopen this issue when we can do Object.setPrototypeOf() in all supported versions of node.

polyfill?

@inca
Copy link
Author

inca commented Mar 11, 2014

Any insights on how Object.setPrototypeOf is any better, performance-wise? AFAIK it is not the __proto__ itself which is discouraged, it is mutating object prototype once it is created.

Citing from MDN:

Mutating the [[Prototype]] of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation. If you care at all about performance, you should never mutate the [[Prototype]] of an object, either using this method or using Object.setPrototypeOf. Instead, create the object with the desired [[Prototype]] using Object.create.

@rlidwka
Copy link
Member

rlidwka commented Mar 11, 2014

AFAIK it is not the __proto__ itself which is discouraged

__proto__ itself is discouraged, because it prevents an arbitrary object to be safely used as a dictionary. Performance is the same obviously.

@inca
Copy link
Author

inca commented Mar 11, 2014

I don't have any arguments to this statement. I am only concerned about MDN mentioning slowing down property access after using either __proto__ or Object.setPrototypeOf.

@expressjs expressjs locked and limited conversation to collaborators Jul 29, 2014
neosiae pushed a commit to neosiae/express that referenced this issue Feb 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants