📜  reduce 方法 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:35.549000             🧑  作者: Mango

代码示例6
function reduce(array, combine, start) {
  let current = start;
  for (let element of array) {
    current = combine(current, element);
  }
  return current;
}

console.log(reduce([1, 2, 3, 4], (a, b) => a + b, 0));
// → 10