GuobaGuoba Utils

isEmpty

@guoba-ai/utils / guard / isEmpty

Function: isEmpty()

function isEmpty(val): boolean;

Defined in: guard.ts:159

Check if a value is empty. Returns true for:

  • null and undefined
  • Empty strings ('')
  • Empty arrays ([])
  • Empty objects ({})

Parameters

val

unknown

The value to check

Returns

boolean

true if the value is considered empty

Example

isEmpty([]) // true
isEmpty({}) // true
isEmpty('') // true
isEmpty(null) // true
isEmpty([1]) // false
isEmpty(0) // false

On this page