My goal is to execute the function checkIsObjectEmptyOrNot
only when the fields "name", "age", and "class" do not contain null values. In case all these values are null (excluding id and book_id), the function should return false. The filtering process must exclude id
and book_id
as they always have values from the Laravel backend.
checkIsObjectEmptyOrNot(object){
for (var key in object) {
if (key != 'id' && key != 'book_id' && key != null) {
break;
return true;
}
}
return false;
}
For example, I have a Json array like this:
[
{
"id": 1,
"book_id": 2,
"name": "myname",
"age": 25,
"class":null,
},
{
"id": 2,
"book_id": 2,
"name": "myname2",
"age": 25,
"class": null,
},
{
"id": 3,
"book_id": 2,
"name": "myname3",
"age": 25,
"class": 10,
},
]