const a = {};
//1.JSON.stringify()
console.log(JSON.stringify(a) === "{}"); //true
//2. es6的方法Object.keys().length
console.log(Object.keys(a)); //[] 返回的是空数组
console.log(Object.keys(a).length); //0
//3.for-in循环
var test = function (obj) {
for (const item in obj) {
return false;
}
return true;
};
console.log(test(a)); //true
网友评论