What is the correct way to get all objectkeys with a false value in an array like this in Javascript:
[
{ unknownkey1 : false },
{ unknownkey2 : true },
{ unknownkey3 : false },
{ unknownkey4 : true },
{ unknownkey5 : false },
{ unknownkey6 : true }
]
Result should be an array containg all keys with a false value.
What I want is a cleaner solution for this:
for(var i = 0; i < results.length; i++ ){
for ( key in results[i] ) {
if ( results[i].hasOwnProperty( key ) && results[i][key] === false ){
console.log( key );
}
}
}
If the value is not false it contains another object. But they are not needed and I would prefere a way that ignores the child objects if possible.