【发布时间】:2015-01-01 21:12:33
【问题描述】:
在 Javascript 中,我有一个对象,我希望删除多个键:
x = {"id":2,"user_id":1,"name":"document_name","description":"the document","file_type":null,"file_id":null}
delete x.file_type
delete x.file_id
结果:
Object {id: 2, user_id: 1, name: "document_name", description: "the document"}
我宁愿在一个命令中删除所有键,也许传递一个键数组?
或者,使用某种类型的下划线/lodash 过滤器来实现相同的目标。
【问题讨论】:
标签: javascript underscore.js lodash