I want an array that contains objects from the scrape
object that are not present in the old
object. The arrays I'm actually working with contains nearly 100 objects.
The code below works, but I wonder if there's a more efficient way of getting the same result?
var old = [
{a: 6, b: 3},
{a: 1, b: 1},
{a: 3, b: 3}
]
var scrape = [
{a: 1, b: 1},
{a: 5, b:5}
]
var nogood = []
var good =[]
scrape.forEach(es => {
old.forEach(e => {
if(e.a == es.a) {
nogood.push(es)
}
})
})
console.log(nogood)
nogood.forEach(main =>
good = scrape.filter(e=> e.a!=main.a)
)
console.log(good)
This is what I expect and what I'm getting:
good = {a:5, b:5}