 
                        输入自已字符串数组,要求输出一个对象 该对象包含每个字符串出现的次数;
代码如下  求解这段代码的意思

 function reduce(arr, fn, initial) {
  return (function reduceOne(index, value) {
    if (index > arr.length - 1) return value // end condition
    return reduceOne(index + 1, fn(value, arr[index], index, arr)) //                          calculate & pass values to next step
  })(0, initial) // IIFE. kick off recursion with initial values
}
module.exports = reduceCopyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
reduce函数对数组中的每一个元素执行指定的函数fn,这个函数fn要求传入的有前一次函数调用的结果,当前迭代元素值,当前迭代元素在原数组中的位置及原始数组,fn函数要返回计算结果作为下一次迭代的第1个参数
等价为==>
可以参考underscore中reduce的说明http://www.css88.com/doc/underscore/#reduce
reduce的中文翻译是归约, 首先你需要了解reduce能做些什么reduce
抽象了遍历逻辑, 使用
reduce, 你可以实现绝大多数的循环逻辑, 如 map, filter...我们再看上面求和的方法
sum的用法和分解reduce接受一个函数function (a, b) {}和一个初始值0, 这里分解一下这个传入函数的执行第一次执行,
a = 0, 也就是初始值;b = 1, 数组的第一项; 返回1第二次执行,
a = 1, 这个1就是函数第一次执行返回数;b = 2, 数组的第二项; 返回3第三次执行,
a = 3...