QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Check if Object is Empty

Checks whether an object has no own enumerable properties.

  • object
  • check
  • empty

Install

npx shadcn@latest add https://quicksnip.dev/r/is-empty-object.json

This snippet is not verified yet. Review it before use, or help verify it.

Code

function isEmptyObject(obj) {
  return Object.keys(obj).length === 0;
}

Usage

isEmptyObject({}); // Returns: true
isEmptyObject({ a: 1 }); // Returns: false