ES6什么是这个三重胖箭头语法

ran*_*its 1 javascript ecmascript-6

进入一些看起来如下的代码:

return store => next => action => {
    switch(action.type) {
    ...
    default:
      return next(action)
};
Run Code Online (Sandbox Code Playgroud)

整个示例如下:https://exec64.co.uk/blog/websockets_with_redux/

这里的三箭头语法是什么?我熟悉箭头函数,但我从未见过多于一个用于定义函数的函数.

mad*_*ox2 7

它是与参数的箭头功能store,其与参数返回另一个箭头函数next返回另一个带有参数action.与常规功能类比如下:

return function (store) {
  return function(next) {
    return function(action) {
      switch(action.type) {
      ...
      default:
        return next(action)
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

只是要注意这个语法:

const myFunction = someParam => someValue
Run Code Online (Sandbox Code Playgroud)

是简写:

const myFunction = someParam => {
  return someValue
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.亲爱的主人,我希望这不是ES6应用程序中的常见做法. (2认同)