【发布时间】:2016-08-06 21:44:41
【问题描述】:
所以,我将一个对象传递给一个 ES6 函数,我想解构 到参数的参数。例如,下面的代码将记录stuff 的data 属性,但我希望它记录stuff 的data 的things 属性。所以正确答案会记录[1,2,3,4]。我知道,一点也不混乱。有人知道这是否可能吗?
const stuff = {
data: {
things: [1,2,3,4]
}
};
const getThings = ({ data }) => {
console.log(data)
};
getThings(stuff);
【问题讨论】: