JavaScript判断object/json 是否为空,可以使用jQuery的isEmptyObject()方法。
function isEmptyObject(e) {
var t;
for (t in e)
return !1;
return !0
}
调用:
console.log($.isEmptyObject({"re": 2})); //false
console.log(isEmptyObject()); //true
console.log(isEmptyObject({})); //true
console.log(isEmptyObject(null)); //true
console.log(isEmptyObject(23)); //true
console.log(isEmptyObject({"te": 2})); //false