Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

2727. Is Object Empty

Easy


Given an object or an array, return if it is empty.

  • An empty object contains no key-value pairs.
  • An empty array contains no elements.

You may assume the object or array is the output of JSON.parse.


Example 1:

obj = {"x": 5, "y": 42}
// Output: false

Explanation :

The object has 2 key-value pairs so it is not empty.

Example 2:

obj = {}
// Output: true

Explanation :

The object doesn't have any key-value pairs so it is empty.

Example 3:

obj = [null, false, 0]
// Output: false

Explanation :

The array has 3 elements so it is not empty.

Constraints :

  • obj is a valid JSON object or array
  • 2 <= JSON.stringify(obj).length <= 105