Appearance
Function: isEmpty()
ts
function isEmpty(value: any): boolean;Defined in: src/utils/isEmpty.ts:19
Check if a value is empty. A value is considered empty if it is:
nullorundefined- A string or array with a length of 0
- A Map or Set with a size of 0
- An object with a
lengthproperty that is 0 - A plain object with no own enumerable properties
Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | The value to check. |
Returns
boolean
true if the value is empty, otherwise false.
Example
ts
const cart = [];
isEmpty(cart); // true
isEmpty({ item: 'coffee' }); // false