I have the following array in javascript:
var myFirstArray = [1,2,3];
and i use $.inArrray() to see if a specific number is in that array like this
var num =3;
var exists = $.inArray(num, myFirstArray) > -1;
I now have an array of objects
var myArray = [{value:1, label:"bird"}, {value:2, label:"dog"}, {value:3, label: "cat"}];
if there anyway to use $.inArray() to search within a field of an object? Something like this:
var num = 3;
var exists = $.inArray(num, myFirstArray, (r) {return r.value}) > -1;
if the answer is NO, is there an alternative function that would give me this behavior that is performant?
inArraydoes not allow a predicate function.