es6 中函数参数列表中的大括号有什么作用? [英] What do curly braces inside of function parameter lists 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
}
这到底是做什么的?我很难在谷歌上找到它,因为我什至不确定它叫什么,或者如何在谷歌搜索中描述它.
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屋!
查看全文