Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Inconsistency .reduce reducer counter argument with Array method #242

Closed
zloirock opened this issue Oct 20, 2022 · 1 comment · Fixed by #243
Closed

Inconsistency .reduce reducer counter argument with Array method #242

zloirock opened this issue Oct 20, 2022 · 1 comment · Fixed by #243

Comments

@zloirock
Copy link
Contributor

With #211:

[1, 2].reduce((a, e, i) => console.log(i)); // => 1

[1, 2].values().reduce((a, e, i) => console.log(i)); // => 0
@ljharb
Copy link
Member

ljharb commented Oct 20, 2022

Indeed, the first invocation of a reduce with no initialValue argument must start its "counter" at 1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants