In case OP stumbles over the destructuring notation, for the given example, the first parameter is the initial value (described with the provided links of the first two comments), working as a collector or accumulator object. It is made up of the first three arguments of another method. The result is written by a destructuring assignment, thus, there will be 3 variables, arg_1
, arg_2
and arg_3
derived from the equally named arguments of the finally returned collector object.
edit, for the OP's provided example code has changed ...
The next example takes the OP's linked SO code reference into account ...
let {slots} = array.reduce(({slots, count, prev}, item)=> {
// ... do something with slots
// ...
// while iterating always needs to return
// an equally structured collector object
return {slots, count: count + 1, prev: item}
}, {slots: [], count: 0, prev: undefined})
/*
return slots; // does not really make sense within this shortened example's context.
*/
... is equal to ...
var slots = array.reduce(function (collector, item) {
var
slots = collector.slots,
count = collector.count,
prev = collector.prev;
// ... do something with slots
// ...
// while iterating always needs to return
// an equally structured collector object
return {slots: slots, count: count + 1, prev: item};
}, {slots: [], count: 0, prev: undefined}).slots;