"Understanding nested arrow functions ES6" 理解嵌套箭头函数ES6

10 浏览
0 Comments

"Understanding nested arrow functions ES6" 理解嵌套箭头函数ES6

这个问题已经有答案了:

多个箭头函数在JavaScript中的含义是什么?

const logger = store => next => action => {
    let result
    console.groupCollapsed("dispatching", action.type)
    console.log('prev state', store.getState())
    console.log('action', action)
    result = next(action)
    console.log('next state', store.getState())
    console.groupEnd()
    return result
}
const store = applyMiddleware(logger)(createStore)(
    combineReducers({ colors, sort })
)

您能否解释一下上面的多箭头函数?

admin 更改状态以发布 2023年5月24日
0
0 Comments

以下代码:\n

const logger = store => next => action => { return 'something'; }

\n等同于:\n

const logger = function(store) { 
    return function(next) {
        return function(action) {
            return 'something';
        }
    }
}

\n可以像以下方式调用: \n

var something = logger(store)(next)(action);

0