I have an array of JS Objects:
var a = [{a:"a1",b:"b",c:"c",prop:false},
{a:"a1",b:"b",c:"c",prop:false},
{a:"a",b:"b",c:"c",prop:false},
{a:"a2",b:"b",c:"c",prop:false},
{a:"a3",b:"b",c:"c",prop:false},
{a:"a1",b:"b",c:"c",prop:false}];
I must find duplicates of the last element but WITHOUT considering the key prop: when I find them, the related prop boolean must be set to true.
I did the simplest thing in the world and it works fine but I was wandering if there is something JS can do (without 3rd party libraries), better either in "elegance", modernity or performance:
var toTest = a[a.length-1];
for(var i=0;i<a.length;i++){
if(toTest.a==a[i].a && toTest.b==a[i].b && toTest.c==a[i].c){
a[i].prop = true;
a[a.length-1].prop = true;
}
}
Any tip is appreciated