var reducers = { totalInEuros : function(state, item) { return state.euros += item.price * 0.897424392; }, totalInYen : function(state, item) { return state.yens += item.price * 113.852; } }; // reducers 是上面reducers 对象 var manageReducers = function(reducers) { // return 是下面 items.reduce 匿名函数 return function(state, item) { console.log(state, item); // state:{euros: 0} item:{price: 10} return Object.keys(reducers).reduce( function(nextState, key) { // 此处为state 进行计算后再返回 reducers[key](state, item); return state; }, {} ); } }; var bigTotalPriceReducer = manageReducers(reducers); var initialState = {euros:0, yens: 0}; var items = [{price: 10}, {price: 120}, {price: 1000}]; var totals = items.reduce(bigTotalPriceReducer, initialState); console.log(totals);