终极:
function checkNullObj(obj) {
return Object.keys(obj).length === 0 && Object.getOwnPropertySymbols(obj).length === 0;
}
var obj = {};
var a = Symbol("a");
var b = Symbol.for("b");
obj[a] = "localSymbol";
obj[b] = "globalSymbol";
console.log(Object.keys(obj).length)//0
console.log(Object.getOwnPropertyNames(obj))// [] 本身不包含对象的 Symbol 属性,只包含字符串属性
console.log(Object.getOwnPropertySymbols(obj)) // [Symbol(a), Symbol(b)]
console.log(Object.getOwnPropertySymbols(obj).length); // 2
console.log(Object.getOwnPropertySymbols(obj)[0]) // Symbol(a)