index Optional The index of the current element being processed in the array. currentValue The current element being processed in the array. It is the accumulated value previously returned in the last invocation of the callback-or initialValue, if it was supplied (see below). It takes four arguments: accumulator The accumulator accumulates callback's return values. Syntax arr.reduce( callback( accumulator, currentValue, ] )) Parameters callbackĪ function to execute on each element in the array (except for the first, if no initialValue is supplied). Your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array, and ultimately becomes the final, single resulting value. The reducer function takes four arguments: If you'd like to contribute to the interactive examples project, please clone and send us a Pull Request. The source for this interactive example is stored in a GitHub repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |