one is to filter first, and then run forEach or for to do things
function test(a) {
this.test.filter(function (i) {
return a.id == i.id;
}).forEach(function (item) {
a.isOpen = !a.isOpen;
});
}
one is to deal with forEach or for directly
function test(c){
for (let i in this.test)
if(test[i].id == c.id)
test[i].isOpen = !cards[i].isOpen
}
The code is for reference only. What I want to know is that when there is a lot of data, filter filters out what you want before running for, is it better than running for directly?