首页 > 代码库 > js 判断空对象

js 判断空对象

let hasObj = false;
for (let i in data.imgPathInfo){
  hasObj = true;
  break;
}
if(!hasObj){
  _this.$message.error(‘图片路径对象为空!‘);
}

jq

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

 

相关文章:http://blog.csdn.net/testcs_dn/article/details/40431835

 

js 判断空对象