content icon indicating copy to clipboard operation
content copied to clipboard

Operators page doesn't mention . or ?.

Open blmatthews opened this issue 10 months ago • 2 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_operators

What specific section or headline is this issue about?

Doesn't really fit the existing sections, maybe a new "Chaining operators" section?

What information was incorrect, unhelpful, or incomplete?

The Expressions and operators page doesn't seem to mention . or ?. at all. Elsewhere (for example, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) they're both called operators, so it seems they should be on the operators page. While . is pretty obvious and used in even the introduction, at least for completeness, it should be on the operators page. ?. isn't as obvious and is (relatively) new, so should definitely be there.

Also, ?? is mentioned in the text in the short-circuiting section in the Logical operators section, but not in any of the operator tables.

What did you expect to see?

At least ?. and probably . as well on the operators page.

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/guide/expressions_and_operators
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_operators
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/guide/expressions_and_operators/index.md
  • Last commit: https://github.com/mdn/content/commit/9b73bdea5458572f77a401596fef9a06ed8bba1b
  • Document last modified: 2024-04-16T06:27:06.000Z

blmatthews avatar Apr 22 '24 20:04 blmatthews

To be clear, you mean calling methods (.), optional chaining (?), and nullish coalescing (??), right?

stephenlf avatar May 03 '24 11:05 stephenlf

Maybe I’m confused or I’m using the terminology wrong, but . isn’t calling methods is it? Math.random doesn’t call the random property of the Math object. And isn’t optional chaining ?.? That’s what it says here and here (which I just discovered and does include ?., ??, and ??=, unlike the guide page).

blmatthews avatar May 03 '24 16:05 blmatthews

?. should be mentioned on this page because it also involves ?.() and ?.[]. ?.property and ?.[] should additionally be mentioned briefly in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects#accessing_properties.

Josh-Cena avatar Jun 05 '24 10:06 Josh-Cena

@blmatthews Would you like to create a PR for this?

hamishwillee avatar Jun 07 '24 00:06 hamishwillee