JavaScript Array.prototype.reduce() index error on page (probably not)

I am new so probably incorrect. However, looking at the example on the reduce() array method has me confused. I know that it’s form works as I have tested it. The thing is the placement of the index (initialValue aka 0) has no model form in the syntax for the method below it. The only time the models show an array AFTER the arrow function is when array is one of the parameters and it isn’t in the example.

Are there more models possible than the syntax shows, or was this a slip up?

Thanks for helping a newbie. I wish MDN had this level documentation on every language as it is stellar on JavaScript!

Hello @William_B

in the callback function section

reduce(callbackFn, initialValue)

that make all arrow function above it can have initialValue so it can be like this

reduce((previousValue, currentValue) => { /* ... */ } )
reduce((previousValue, currentValue) => { /* ... */ } ,initialValue)

reduce((previousValue, currentValue, currentIndex) => { /* ... */ } )
reduce((previousValue, currentValue, currentIndex) => { /* ... */ } ,initialValue)

reduce((previousValue, currentValue, currentIndex, array) => { /* ... */ } )
reduce((previousValue, currentValue, currentIndex, array) => { /* ... */ }, initialValue)

callback function is same as arrow but it just function without name and we write it’s implementations where it been called

and you can apply same rule for Inline callback function section

but if you see they should write it down then you can go to the end of the page and edit the github page and they could accept your pool request

by the way your email is shown you can hide it from your profile page

hope that help and have a nice day :slight_smile:

Thanks for the heads up on the email… I auto-filled and made a mistake.

There is this:

reduce((previousValue, currentValue, currentIndex, array) => { /* ... */ }, initialValue)

but that would seem to say that the ONLY way you can have initialValue is if currentIndex and array are present, or why else would it be presented only that way. According to the discussion of parameter values beneath these syntax examples, only initialValue is indicated as optional.

you very welcome

i agree there a points of what you saying specialy for new learner that could confuse them

that why i said

so hope it help and have a nice day :slight_smile: