const isEmpty = Object.keys(data).every((key) => {
return data[key].length === 0;
});
How can I check if all arrays in objects are empty. Problem with this code I tried is that I get this:
data {
0: Array[]
1: Array[]
2: Array[]
}
data {
0: Array[]
1: Array[1]
2: Array[]
}
For first object I get false and that's okay but for the second I get true but I want to get false until all of arrays.length > 0, so I need to get true only for this situation:
obj {
0: Array[1]
1: Array[1]
2: Array[1]
}
arrays.length > 0. Then why don't you use it instead oflength === 0?datais completely invalid. What shouldArray[0]be? If that is really your code, that will not return false or true but just throw errors ...Array[0]etc.? if you mean an array with 0 elements then your solution will givetruefor the first andfalsefor the second, notfalsefor the first andtruefor the second. Also, your desired result is unclear, you say you want it to be true until all ofarrays.length > 0, but then say "I need to get true only for this situation", which suggests you wanttrueonly when allarrays.length's equal 1