I need to find out, is there in array of objects object with the certain key:value For example if I need the key 'id' to be unique:
arr=[
{id:1, attr1:'435',attr2:'sdg'},
{id:2, attr3:'4x35',attr2:'sdg'}
];
a={id:1,attr2:'nnsklnf'};
b={id:3,attr3:'kldfmlkdblng'};
function isHaveSimilar(_a,_array){
// ... ???
}
isHaveSimilar(a,arr); // true
isHaveSimilar(b,arr); // false
Maybe there is some easier way than the rude checking of the each element? Thx)