I am trying to determine whether a object contains a specific value so that I can be sure not append the value I am looking for more than once and prevent recursion.
I have tried lots of methods but can't get any of them to work:
data = [
{val:'xxx',txt:'yyy'},
{val:'yyy',txt:'aaa'},
{val:'bbb',txt:'ccc'}
];
console.log(jQuery.grep(data, function(obj){
return obj.txt === "ccc";
}));
$.map(data, function(el) {
if(el.txt === 'ccc')
console.log('found')
});
Can this be done with map() grep() or inArray() or do I really have to loop through the entire array looking for the value ??