let testObj = {}
let array = Object.getOwnPropertyNames(testObj)
if(array.length == 0) {
console.log("数据为空")
}
1、ES6方法Object.keys()
let testObj = {}
console.log(Object.keys(testObj).length === 0) //true
2、for...in
for(let i in testObj){
console.log("不为空")
}
3、JSON.stringfy(),将json对象转化为json字符串
if(JSON.stringfy(testObj) === '{}'){
console.log("Object为空!")
}
4、Object.getOwnPropertyNames()
let testObj = {}
let array = Object.getOwnPropertyNames(testObj)
if(array.length == 0){
console.log("Object为空")
}