【发布时间】:2020-08-06 11:47:30
【问题描述】:
所以问题很容易解释...我得到了 id 我需要从数组(allIds)和对象(byIds)中删除它。
const DUMMY_PLACES = [
{
todos: {
allIds: [1, 2, 3, 4],
byIds: {
"1": {
content: "test1",
completed: false,
},
"2": {
content: "test2",
completed: false,
},
"3": {
content: "test3\\",
completed: false,
},
"4": {
content: "test4",
completed: false,
},
},
},
visibilityFilter: "all",
},
];
对于数组(allIds 我找到了怎么做
DUMMY_PLACES[0].todos.allIds = DUMMY_PLACES[0].todos.allIds.filter(
(allId) => allId !== id
);
【问题讨论】:
标签: javascript arrays algorithm object