delete object.niddelete object.uuiddelete object.desktopdelete object.isHidedelete object.sortIddelete object.dateBean类似这种需要删除很多个元素的有什么优雅的写法吗?
1 回答
四季花海
TA贡献1811条经验 获得超5个赞
把key
值放到一个数组中,然后循环删除key
值:
var keys = ["nid", "uuid", "desktop", "isHide", "sortId", "dateBean"];
keys.forEach(function(item) {delete object[item]});
添加回答
举报
0/150
提交
取消