I'm looking for more elegant and efficient way to toggle object in array.
So my arr is:
let arr = [
{id: 2},
{id: 3},
...
]
Now I'm doing it like this:
if (arr.find(function(element) { return element.id === upload.id } )) {
arr = arr.filter(function(element) {
return element.id !== upload.id;
});
}
else {
arr.push(upload)
}