javascript-tutorial / javascript-tutorial/en.javascript.info

optional chaining: error in summary?

Open
#2,764 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
25.5k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

The Summary section of page https://javascript.info/optional-chaining reads:

  1. obj?.prop – returns obj.prop if obj exists, otherwise undefined.
    
  2. obj?.[prop] – returns obj[prop] if obj exists, otherwise undefined.
    
  3. obj.method?.() – calls obj.method() if obj.method exists, otherwise returns undefined.
    

but it seems that the first 2 lines should rather say:

  1. ... obj.prop if obj.prop exists...
  2. ...obj[prop] if obj[prop] exists...
    => actually in both cases when obj does not exist, as explained before in the chapter, it will throw an error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the optional chaining chapter at the linked javascript.info page and compare the Summary wording with the preceding explanation of property and method access. Update the two summary bullets if the explanation confirms the reported distinction, then review the rendered page to ensure the summary is accurate and clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.