I want to make sure that two properties (referencing objects) connected and connections both contain at least one property, like this:
if ((Object.keys(layer[i1].connected).length > 0
&& Object.keys(layer[i1].connections).length > 0) || /* other logic omitted */) {
//do stuff
}
That works so far. But I realized I need to make sure not only that properties exist within connected and connections but also that those contents contain the property active which is equal to true.
So the contents need to be:
connections : { //at least one is true
34 : {
active : true
},
37 : {
active : false
},
38 : {
active : false
}
}
and (&&)
connected : { //at least one is true
12 : {
active : true
},
22 : {
active : true
}
}
not
connections : {
34 : {
active : false
},
}
or
connected : {}
I'm just wondering if there's a simple, elegant way to perform this kind of check rather than the messy options I'm thinking of. Is there an elegant way to do this? Obviously there are many ways to do it, but I'm really interested in a one-line approach, similar to how Object.keys very neatly exposes the number of properties.