So I need to pass in a object where each of its properties are arrays. The function will use the information held in each array, but I want to check if the whole object is empty empty (not just having no properties) by checking if each of its arrays are empty/null as well. What I have so far:
function isUnPopulatedObject(obj) { // checks if any of the object's values are falsy
if (!obj) {
return true;
}
for (var i = 0; i < obj.length; i++) {
console.log(obj[i]);
if (obj[i].length != 0) {
return false;
}
}
return true;
}
So for example, this would result in the above being false
:
obj {
0: Array[0]
1: Array[1]
2: Array[0]
}
While this is the empty I'm checking for (so is true):
obj {
0: Array[0]
1: Array[0]
2: Array[0]
}
The above code doesn't work. Thanks in advance.