178
rated 0 times
[
184]
[
6]
/ answers: 1 / hits: 96724
/ 11 Years ago, thu, october 10, 2013, 12:00:00
I wanted to check if the an object has a property of something and its value is equal to a certain value.
var test = [{name : joey, age: 15}, {name: hell, age: 12}]
There you go, an array of objects, now I wanted to search inside the object and return true if the object contains what I wanted.
I tried to do it like this:
Object.prototype.inObject = function(key, value) {
if (this.hasOwnProperty(key) && this[key] === value) {
return true
};
return false;
};
This works, but not in an array. How do I do that?
More From » jquery