是否通过直接替换列表来改变数据

时间:2018-04-15 01:23:33

标签: javascript mutators

以下代码是否会改变history?如果它确实如何避免它。

const index = findIndex(propEq('editorId', editorId))(editorWrappers);

if (index !== -1) {
    const editorHistory = editorWrappers[index].history || [];
    const history = filter(item => item.resource !== resource || (item.resource === resource && item.name !== name), editorHistory);
    console.log('history', history);
    editorWrappers[index].history = history;
}

return [...editorWrappers];
};

0 个答案:

没有答案