如何在JavaScript中忽略对象的特定属性 [英] How to omit specific properties from an object in JavaScript
本文介绍了如何在JavaScript中忽略对象的特定属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种干净的方法来返回一个新对象,而该对象忽略了原始对象包含的某些属性,而不必使用lodash之类的东西?
Is there a clean way to return a new object that omits certain properties that the original object contains without having to use something like lodash?
推荐答案
const { bar, baz, ...qux } = foo
现在,对象qux
具有foo
的所有属性,除了bar
和baz
.
Now your object qux
has all of the properties of foo
except for bar
and baz
.
这篇关于如何在JavaScript中忽略对象的特定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文