Skip to content

isEmpty ​

The isEmpty function checks if a value (object, array, string, Map, or Set) is empty.

Syntax ​

typescript
isEmpty(value): boolean

Parameters ​

NameTypeDescription
valueanyValue to be checked.

Return ​

TypeDescription
booleanReturns true if the value is empty, otherwise false.

Examples ​

typescript
isEmpty({}); // true
isEmpty([]); // true
isEmpty(''); // true
isEmpty({ a: 1 }); // false
isEmpty([1, 2]); // false

Notes ​

  • Supports objects, arrays, strings, Map, and Set.
  • Returns true for null.

References ​

Released under the MIT License.