# 判断是否是一个空对象

  • 使用 JSON.stringify 方法来判断。

JSON.stringify(obj) == '{}' // true
  • 使用 Object.keys()
Object.keys(obj).length === 0; // true  空对象。