I'm looking for a method which will generically checks if an Array contains an object with the exact same param values.
Not something specific, a generic implementation.
Exemple :
var obj1 = {name : 'name1', id : 1, value : 'value1'};
var obj2 = {name : 'name2', id : 2};
var obj3 = {name : 'name3', id : 3, value : 'value1', title : 'title3'};
var obj4 = {name : 'name4', id : 4, value : 'value1', title : null};
var arrayObj = [obj1, obj2, obj3, obj4];
var test1 = {name : 'name1', id : 1}; // One missing attribut
var test2 = {name : 'name2', id : 2, value : 'value2'}; // One additional attribut
var test3 = {name : 'name3', id : 3, value : 'value1', title : 'title33'}; // attribut with different value
var test4 = {name : 'name4', id : 4, value : 'value1'}; // same attributs beside the null one
var test5 = {name : 'name3', id : 3, value : 'value1', titleBis : 'title3'}; // attributs with different names
var test6 = {value : 'value1', id : 1, name : 'name1'}; // same attributs and attributs value but in different order
containsMethod(arrayObj, test1); // false
containsMethod(arrayObj, test2); // false
containsMethod(arrayObj, test3); // false
containsMethod(arrayObj, test4); // true
containsMethod(arrayObj, test5); // false
containsMethod(arrayObj, test6); // true
containsMethod(arrayObj, obj2); // true
Please let me know in comment if it's not clear. I've seen a lot of question for specific object, here I'm looking for a generic version.
Ideally this would also work for String, number etc, not only object with attributs