如何从JavaScript对象中删除项目?
像这样:
var test = {'red':'#FF0000', 'blue':'#0000FF'};
test.remove('blue');
答案 0 :(得分:630)
var test = {'red':'#FF0000', 'blue':'#0000FF'};
delete test.blue; // or use => delete test['blue'];
console.log(test);
这会删除test.blue