如何从javascript对象中移除项

How to remove item from a JavaScript object

本问题已经有最佳答案,请猛点这里访问。

Possible Duplicate:
How to remove a property from a javascript object

如何从javascript对象中删除项?

这样地:

1
2
var test = {'red':'#FF0000', 'blue':'#0000FF'};
test.remove('blue');


1
2
3
var test = {'red':'#FF0000', 'blue':'#0000FF'};
delete test.blue; // or use => delete test['blue'];
console.log(test);

这将删除test.blue