In Mozilla's Reduce docs page I found the syntax below:
arr.reduce(callback[, initialValue])
The square brackets throw me off.
I have code like this that works:
const selectedItems = selectedItemsList.reduce((itemObject, item) => {
return {
...itemObject,
[item]: this.props.areasList.find(area => area.id === item)
};
}, {});
I do not use square brackets. I provide a callback and an initial value, separated by a comma. Can anyone elaborate on why the doc shows the syntax that it does for reduce? I only figured out the code in this post that I have by looking at other examples.