var arr1= [];
var value = "value";
if ($.inArray(value, arr1) !== -1){
//value found
}
To check for a value if it exist in array we use above code. What i need is to check a value from an array if it exist in another array. What i did is below. But i am not certain why i always get not found even if in the array there is a same value. Any suggestion is appreciated
var arr1 = [{
"id": "1"
}, {
"id": "2"
}]
var arr2 = [{
"id": "2"
}, {
"id": "3"
}]
$.each(arr2, function (index, value) {
console.log(value.id);
if ($.inArray(value.id, arr1) !== -1) {
alert('found');
} else {
alert('q');
}
});