lodash 中 remove
var obj = { "objectiveDetailId": 285, "objectiveId": 29, "number": 1, "text": "x", "subTopics": [{ "subTopicId": 1, "number": 1 }, { "subTopicId": 2, "number": 32 }, { "subTopicId": 3, "number": 22 }] } var stToDelete = 2; _.remove(obj.subTopics, function(item, index, models) { return item.subTopicId === stToDelete; }); _.remove(obj.subTopics, { subTopicId: stToDelete });
item:当前循环项
index:当前索引值
modes:循环的数组