Skip to content

如何判断一个对象是不是空对象?

参考答案:

js
// 方法1
Object.keys(obj).length === 0

// 方法2
JSON.stringify(obj) === '{}'