Closed
Bug 1311033
Opened 9 years ago
Closed 9 years ago
candidate: change the example to encourage use of Object.create() instead?
Categories
(Developer Documentation Graveyard :: JavaScript, enhancement)
Developer Documentation Graveyard
JavaScript
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: osprey, Unassigned)
References
()
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20160922113459
Steps to reproduce:
Urgency: Certainly not critical. Perhaps quite low.
The subject here is the code example at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
. It is just under the heading "Custom Error Types". It uses Object.setPrototypeOf().
Actual results:
In contrast, at the top of
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
there is a red box listing concerns with using Object.setPrototypeOf() and concluding "Instead, create a new object with the desired [[Prototype]] using Object.create()."
Expected results:
If the red box information is right, the example on the Error page might improve by either (1) demonstrating use of Object.create() instead, or (2) both (a) briefly explaining the challenges with Object.setPrototype() and (b) also demonstrating use of Object.create().
This is not a gripe. MDN is my prime reference for JavaScript information. Well done! If this doesn't help, please ignore it.
If there's a way to edit my submission, I'm not finding it. That makes this writeup a little less clear. So sorry.
My entry was partly incomplete. It correctly indicated the Error page uses Object.setPrototypeOf(). It would have better indicated the Error page uses both Object.setPrototypeOf() and Object.create().
Noting that, my suggestion would be better this way: If the red box information is right, the example on the Error page might improve by showing two examples (one with both functions and one with only Object.create()) with an explanation of the difference in results (both positive and negative).
I regret any inconvenience.
Updated•9 years ago
|
Component: MDN Meta Docs → JavaScript
Comment 2•9 years ago
|
||
I removed setPrototypeOf from the example. I think it isn't necessary.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•