One of the best and simple solution
function hasValue(obj, key, value) { return obj.hasOwnProperty(key) && obj[key] === value; } var test = [{name : "joey", age: 15}, {name: "hell", age: 12}] console.log(test.some(function(boy) { return hasValue(boy, "age", 12); }));
No comments:
Post a Comment