arrow functions: destructuring arguments and grabbing them as a whole at the same time

时光总嘲笑我的痴心妄想 提交于 2019-12-06 07:14:35

You can use default parameters and object rest at target of destructuring assignment for first parameter, where a single object is expected, and optionally define subsequent parameters by destructuring previously defined object parameter

const fn = ({...args} = {}, {a, b} = args) => console.log(a, b, args);

If you mean that f also accepts named parameters, so why not just use:

(params) => {
  const { a, b } = params
  return a + b + f(params)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!