![]() ![]() ![]() If we do not provide the initial value, the callback function will start its execution with index as 1, where it will skip the first index.InitialValue: It is the first argument value used in the first invocation of the callback function. array: It is also optional, which carries the elements on which the reduce() will work.If we provide the initial value, indexing will begin from 0. currentIndex: It is an optional argument that holds the index value of the current element which is being processed.currentValue: It is the value of the current element, which is being processing.accumulator: It accumulates the return values of the callback function, returned in the last calling of the function.The callback function undertakes the following four arguments: Arr.reduce(callback(accumulator, currentValue, currentIndex, array), initialValue)Ĭallback: The main is the callback function that executes for each element, excluding the first, if no initialValue is specified. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |