我正在尝试使用解构一次从对象中删除多个计算属性。像这样的东西
const a = {b: 1, c: 2 , d: 3};
const forbiddenKeys = [ "b", "c"]; // pretend this is computed
const { ...forbiddenKeys, ...rest } = a; // gives "Uncaught SyntaxError: Rest element must be last element"
我的计划是rest
在这些操作之后使用变量来获取未包含在forbiddenKeys
. 有没有办法做到这一点,使其像这里的“对象解构中的休息”部分一样工作?https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Computed_object_property_names_and_destructuring