在es6中,大括号内的函数参数列表是做什么的? [英] What do function parameter lists inside of curly braces do in es6?
本文介绍了在es6中,大括号内的函数参数列表是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我正在处理的代码库中,我继续看到这样的功能:
I keep seeing functions that look like this in a codebase I'm working on:
const func = ({ param1, param2 }) => {
//do stuff
}
这是做什么的?我很难在谷歌上找到它,因为我甚至不知道这是什么,或者如何在google搜索中描述它。
What exactly is this doing? I'm having a hard time finding it on google, because I'm not even sure what this is called, or how to describe it in a google search.
推荐答案
它是解构,但包含在参数。没有解构的等价物将是:
It is destructuring, but contained within the parameters. The equivalent without the destructuring would be:
const func = o => {
var param1 = o.param1;
var param2 = o.param2;
//do stuff
}
这篇关于在es6中,大括号内的函数参数列表是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文