Editorial: clarify that reduce skips first call based on initialValue#3818
Open
michaelficarra wants to merge 1 commit intomainfrom
Open
Editorial: clarify that reduce skips first call based on initialValue#3818michaelficarra wants to merge 1 commit intomainfrom
michaelficarra wants to merge 1 commit intomainfrom
Conversation
linusg
approved these changes
Apr 9, 2026
| <h1>Array.prototype.reduce ( _callback_ [ , _initialValue_ ] )</h1> | ||
| <emu-note> | ||
| <p>_callback_ should be a function that takes four arguments. `reduce` calls the callback, as a function, once for each element after the first element present in the array, in ascending order.</p> | ||
| <p>_callback_ should be a function that takes four arguments. `reduce` calls _callback_ once for each element present in the array, in ascending order, skipping the first element unless _initialValue_ is provided.</p> |
Member
There was a problem hiding this comment.
_callback_ is actually called with the first element, just as the first value rather than the second one. I wonder if the next paragraph might be enough to explain that we "skip" the first value, and here we could just write something like this? Without mentioning where we start from, or that we it is called on all elements.
Suggested change
| <p>_callback_ should be a function that takes four arguments. `reduce` calls _callback_ once for each element present in the array, in ascending order, skipping the first element unless _initialValue_ is provided.</p> | |
| <p>_callback_ should be a function that takes four arguments. `reduce` calls _callback_ on the elements present in the array, in ascending order.</p> |
Member
Author
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Member
Author
There was a problem hiding this comment.
I don't know how you're getting that from what I posted. The function is not called.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.