Check if Javascript Object only contains falsy values
As a one-liner:
!Object.keys(obj1).some(function(k) {return obj1[k];});
// Array.some returns true if any callback returns true
// You want true if all return false, aka if none return true
// So just negate Array.some
As a more readable method:
var ok = true, k;
for( k in obj1) if( obj1.hasOwnProperty(k)) {
if( obj1[k]) {
ok = false;
break;
}
}