An attribute of the same name is added if the object cannot obtain a value
Format :(variable in object)
When “object” is an array, “variable” refers to the “index” of the array.
When “object” is an object, “variable” refers to “properties” of the object.
True returns true
arr.reduce(callback(accumulator, currentValue[currentIndex[, sourceArray]])[, initialValue])
The reducer function receives four parameters:
Accumulator (ACC) : The return value of the Accumulator callback; It is the cumulative value, or initialValue, returned when the callback was last called.
CurrentValue (cur) : The element being processed in the array.
CurrentIndex (idx) (CurrentIndex) : (optional) index of the current element being processed in the array.
SourceArray (SRC) (SourceArray) : (optional) array of calls to reduce().
InitialValue: The value of the first argument when the callback function is first called.
Note: When the callback function is executed for the first time, accumulator and currentValue are of two different values: If initialValue is provided when reduce() is called, accumulator is initialValue and currentValue is the first value in the array. If no initialValue is provided, accumulator takes the first value in the array and currentValue takes the second value in the array.