Reputation: 2608
Hi I would like to find a condition in jquery to be sure that the id
of the data found by .grep
is different from all the values from a vector, with something like this :
var matchedAgainstBrand = $.grep(prodata, function(v,i) {
return v['id'] !== matchedProIds ;
});
or this
var matchedAgainstBrand = $.grep(prodata, function(v,i) {
return $.inArray( v['id'], matchedProIds ) == -1;
});
(but these two do not work !)
where matchedProIds
is a vector of integers, defined like this :
var matchedProIds = [];
for (i=0; i< matchedPro.length; i++) {
matchedProIds.push(matchedPro[i]['id']);
}
Can you help with a condition that (un)match a value against a vector ?
Upvotes: 0
Views: 31
Reputation: 2608
Thanks to the suggestion from @Matt Burland :
var matchedAgainstBrand = $.grep(prodata, function(v,i) {
return matchedProIds.indexOf(v['id']) == -1;
});
Upvotes: 1