数组对象统计多个属性

48 阅读1分钟

const sum = data.reduce((accumulator, currentValue) => { const { left, width } = currentValue; return { left: accumulator.left - left, width: accumulator.width + width }; }, { left: 0, width: 0 });