I have an array of objects in javascript (D3) and I need to remove every object of which a certain attribute is present in another array of objects attribute,
i.e. a left outer join
(source: tazindeed.co.uk)
I managed to do it myself with 2 loops but it's quite slow.
And I don't know how to make it faster.
for (var i = 0; i < data1.length; i++) {
for (var j = 0; j < data2.length; j++) {
if (data2[j].attr3 == data1[i].attr4) {
data2.splice(j,1);
}
}
}
data1.length~2k and data2.length~10k
I know this has approximately been asked here but it's been almost 2 years and the solutions use external libraries.
I'm just curious to learn if there is a better method with javascript (or jQuery or D3, which I already use)
Thank you for your help !