说我有一个对象,看起来像对象键此使用保留关键字与传播运营商
const props = {
delete: function() {
// stuffs
},
hello: 'hello',
other: 'other',
}
现在说我用传播经营者和做这样的事情
const {hello, ...otherStuffs} = props;
那么对于otherStuffs,我仍然收到一个props
的副本,但hello
键除外。
但是如果我不想要该对象的delete
键?我不能这样做,因为显然delete
是保留关键字。
const {delete, ...otherStuffs} = props; // error here
我仍然不过从过滤的对象不等于“删除”,并让我的对象,但有没有办法做到这一点使用扩展运营商的钥匙?
对象传播语法不ES6。 – Bergi