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

Misleading Explanation About Comma Operator Precedence

Open
#3,667 2 comments 0 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

Hi there,

I've come across a section in the documentation (https://javascript.info/operators#comma) that explains the precedence of the comma operator.
image

However, it seems to have an error in its explanation. The example provided suggests that a = 1 + 2, 3 + 4 should result in a being assigned the value 3, whereas in reality, it correctly returns 7.
image

I believe this discrepancy could lead to confusion among learners, and the explanation might need clarification to reflect the actual behavior of the comma operator. Thank you for your attention to this matter!

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

Review the comma operator section linked in the issue and verify the example against JavaScript's operator precedence and evaluation behavior. Clarify the explanation so the documented result and assignment behavior are unambiguous, then confirm the revised text matches the language behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.