I seem to be using this test a lot
if( object && object !== \"null\" && object !== \"undefined\" ){
doSomething();
}
on
If you have jQuery, you could use $.isEmptyObject()
.
$.isEmptyObject(null)
$.isEmptyObject(undefined)
var obj = {}
$.isEmptyObject(obj)
All these calls will return true. Hope it helps
if(!!object){
doSomething();
}
Maybe like this:
var myObj = {};
var isEmptyObj = !Object.keys(myObj).length;
if(isEmptyObj) {
// true
} else {