Is an Object with a Property in my Array?
JavaScriptThis post is old. Codes, opinions and facts could be outdated.
Help to fix potential errors: GitHub
The following code can be used to test whether an object in an 'array' array has a 'property' property with the value 'value':
// test if a object located in 'arrray' has a 'property' which equals 'value'
var isInArray = function (array, property, value) {
for (var i=0; i < array.length; i++) {
if (array[i][property] === value) return true;
}
return false;
};