如何从JavaScript对象中删除项目

如何从JavaScript对象中删除一个项?

是这样的:

var test = {'red':'#FF0000', 'blue':'#0000FF'};
test.remove('blue');
455571 次浏览

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

这将删除test.blue