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.
{}andObject.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: returnfalse(they are not objects).- A property whose value is
undefinedstill counts as a key.
Example 1
- Input
- isEmptyObject({}), isEmptyObject({ a: 1 })
- Output
- true, false
Constraints
- value can be of any type.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.