Skip to content
Onsite

Check if Object Is Empty

EasyP3Coding

Implement isEmptyObject(value), which returns true if value is an object with no own enumerable string keys, and false otherwise.

  • {} and Object.create(null) are empty.
  • An object whose only properties are inherited from its prototype is empty.
  • [] is an object with no keys, so it is empty; [1] is not.
  • null, undefined, numbers, strings, booleans: return false (they are not objects).
  • A property whose value is undefined still counts as a key.

Example 1

Input
isEmptyObject({}), isEmptyObject({ a: 1 })
Output
true, false

Constraints

  • value can be of any type.

Hints

Run checks the 3 visible tests, Submit all 8.