我有一个像以下的对象:
Object {w74: Object, w100: Object,w12: Object,w3: Object}
我需要腾出其中一个
Object {w74: Object, w100: Object,w3: Object}
如何在javascript中删除此内容
答案 0 :(得分:4)
var ob = {w74: {number: 1}, w100: {number: 2},w12: {number: 3},w3: {number: 4}};
console.log(ob);
delete ob.w74;
console.log(ob);

答案 1 :(得分:1)
您可以按关键值
直接从对象中删除您的值例如。
var arrChildOptions2 = {
w74: Object, w100: Object,w12: Object,w3: Object
};
delete arrChildOptions2.w12;
答案 2 :(得分:0)
使用名为_.pick()http://underscorejs.org/#pick
的下划线库函数_.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');
=> {name: 'moe', age: 50}
_.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
return _.isNumber(value);
});
=> {age: 50}