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

Add __proto__ key initializer to "Inheritance and the prototype chain" #16090

Merged
merged 9 commits into from
May 17, 2022

Conversation

Josh-Cena
Copy link
Member

@Josh-Cena Josh-Cena commented May 16, 2022

Summary

Motivation

Close #16068

Supporting details

I've run some benchmarks:

https://jsben.ch/vLqVS

The __proto__ key turns out to be the fastest!

Related issues

Metadata

  • Adds a new document
  • Rewrites (or significantly expands) a document
  • Fixes a typo, bug, or other error

@Josh-Cena Josh-Cena requested a review from a team as a code owner May 16, 2022 03:39
@Josh-Cena Josh-Cena requested review from sideshowbarker and removed request for a team May 16, 2022 03:39
@github-actions github-actions bot added the Content:JS JavaScript docs label May 16, 2022
@Josh-Cena
Copy link
Member Author

Josh-Cena commented May 16, 2022

TBH, I'm not entirely sure what the organization of this page is. We have "Different ways to create objects and the resulting prototype chain" as an H2 heading, and then "Summary of methods for extending the prototype chain" as a child H3 heading, which seems to describe how to create an object (inst) with a given prototype chain as well? Am I missing some nuance here?

On second thought I think maybe I can move my section to be parallel with class keyword, instead of parallel with Object.prototype.__proto__, but it's all a bit messy around here.

@sideshowbarker
Copy link
Collaborator

On second thought I think maybe I can move my section to be parallel with class keyword, instead of parallel with Object.prototype.__proto__, but it's all a bit messy around here.

That might be better yeah — but agreed, the organization of the page overall leaves a bit to be desired

@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2022

Preview URLs

Flaws

None! 🎉

External URLs

URL: /en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
Title: Inheritance and the prototype chain
on GitHub

No new external URLs

(this comment was updated 2022-05-17 11:18:17.182930)

console.log(inst.bar_prop);
```

<table class="standard-table">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers: the reason this is an HTML table here rather than a Markdown table is that the corresponding existing sections of this article use similar HTML tables — so this is following the existing structure.

Probably we should replace all the HTML tables in the docs with Markdown tables, but that’s outside the scope of this patch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, I'm not entirely sure how that can be converted to a Markdown table: is there a syntax for <caption>?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, I'm not entirely sure how that can be converted to a Markdown table: is there a syntax for <caption>?

The equivalent is to just have a paragraph that precedes the table.

@Josh-Cena
Copy link
Member Author

Josh-Cena commented May 16, 2022

/en-US/docs/Web/JavaScript/Reference/Object_initializer does not exist

Proof that I don't understand the KumaScript syntax... Need some guidance on how to point to the right document. Is using URL links the only way?

@sideshowbarker
Copy link
Collaborator

/en-US/docs/Web/JavaScript/Reference/Object_initializer does not exist

Proof that I don't understand the KumaScript syntax

In general it’s always OK to not use a KumaScript macro at all but instead just use a normal Markdown hyperlink — for example, object initializer

(Also worth mentioning that it’s OK to assume that existing content may have been written in a way that doesn’t follow current best practices, so you’re free to use your judgement to depart from the whatever (potentially bad) precedents may exist in whatever content you may be updating.)

@Josh-Cena
Copy link
Member Author

Being a first-time contributor, I'm not really aware of what the best practices for MDN is. And TBH, as a docs framework developer myself, the biggest complaint I've heard is that "URL links are not stable enough" and "we want immutable doc references" which jsxref seems to be about😄

@Josh-Cena
Copy link
Member Author

Josh-Cena commented May 16, 2022

On second thought I think maybe I can move my section to be parallel with class keyword, instead of parallel with Object.prototype.__proto__

After a few re-reads I think I've got the gist of how the two places differ. I think the current approach makes more sense, but it's definitely not immediately apparent to a reader what the logical division is.

@Josh-Cena
Copy link
Member Author

I'm slightly confused about the Netlify deploy preview: is it enabled for MDN?

@sideshowbarker
Copy link
Collaborator

I'm slightly confused about the Netlify deploy preview: is it enabled for MDN?

Dunno — where do you see it mentioned?

@Josh-Cena
Copy link
Member Author

Ah, the action seems to be mdx-contributor-docs, which is not the same as the docs I'm editing.

@Josh-Cena Josh-Cena requested a review from sideshowbarker May 17, 2022 09:02
@sideshowbarker sideshowbarker merged commit 1e818c7 into mdn:main May 17, 2022
@sideshowbarker
Copy link
Collaborator

Joshua, thanks much, and congrats on landing your first docs change here — welcome aboard 🎉

@Josh-Cena Josh-Cena deleted the proto-initializer branch May 17, 2022 11:18
@Josh-Cena
Copy link
Member Author

Thank you! ⭐️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs
Projects
None yet
3 participants