如何在隐式返回中使用扩展运算符,其中我正在从对象数组中删除一个键值。我可以使用显式返回,但我需要该场景的简码和其他可能的解决方案。
foldl
答案 0 :(得分:0)
只需返回rest
,就无需再次传播它。
注意:要从箭头函数返回对象,请将对象包装在()
中。但是这里您不需要。
let array = [
{"sales":2341,"targetMet":false,"advertisment":true},
{"sales":981,"advertisment":true},
{"sales":3423,"targetMet":true,"advertisment":false},
];
let expectedArray = array.map(({targetMet,...rest}) => rest);
console.log(expectedArray)