I'm wanting to know how to check if an object still exists in an array
var a = [{ "id": 1, "name": "Jeffery" }, { "id": 2, "name": "Jimmy" }]
I'm trying to find if Jeffery
is still in this array:
var obj = { "names": { "Jeffery": { "age": 43, "job": "Doctor" }, "Jimmy": { "age": 23, "job": "Developer" } } };
I've attempted to use this code which brings no luck. Am I doing anything wrong?
function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}