mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.16k stars 22.46k forks source link

Problem with page title "Array.prototype.length": `length` is an own property of array #16325

Closed Josh-Cena closed 2 years ago

Josh-Cena commented 2 years ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

Title: "Array.prototype.length"

What did you expect to see?

It should be Array.length, maybe? We don't really have a standard way to represent own properties of instances.

The same goes for Error properties like "Error.prototype.message".

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details * Folder: `en-us/web/javascript/reference/global_objects/array/length` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/reference/global_objects/array/length/index.md * Last commit: https://github.com/mdn/content/commit/6d01bb5d3619ffe13649b9951e7c6b76d0555788 * Document last modified: 2022-03-31T03:05:00.000Z
hamishwillee commented 2 years ago

In the JavaScript section of MDN using prototype in the title - such as Array.prototype.length is how you indicate that it is an instance variable. If it was Array.length you would know it was a static variable.

There is a proposal for Web APIs to make things more explicit by having static in the title for static fields. Personally I want that approach rolled into JavaScript as well, but that has not been agreed.

hamishwillee commented 2 years ago

Closing, because this is correct.

Josh-Cena commented 2 years ago

In this case, should the other pages where we do use Class.instanceProperty format be corrected, then? e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length

hamishwillee commented 2 years ago

In the general case yes. @wbamberg do you have a view on this? The context is JavaScript instance variables that do not have prototype in the name.

The only reason I question this is that there might be some "know exceptions to the rule".

wbamberg commented 2 years ago

In this case, should the other pages where we do use Class.instanceProperty format be corrected, then? e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length

I....guess so? Note that we do use prototype in the names where we link to Function.length: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function#instance_properties. So we're not even consistent within a single property.

It does seem wrong though. To me this is another argument that the JS docs should be included in https://github.com/mdn/content/discussions/5121.

So maybe rather than "fixing" them to be consistent with the existing convention, we should adopt the resolution in https://github.com/mdn/content/discussions/5121#discussioncomment-785747.

hamishwillee commented 2 years ago

It does seem wrong though. To me this is another argument that the JS docs should be included in https://github.com/mdn/content/discussions/5121.

@wbamberg Well, you know I strongly feel that they should be treated the same way as web APIs. But IMO this is more a strong argument for "consistency".

I think we do all the WebAPIs then push the same logic through JavaScript too.

hamishwillee commented 2 years ago

In summary @Josh-Cena Probably yes. For now that would be the rule.