IsEmpty

Returns whether or not a given value is "empty". The following data types can be checked:

  • Strings (a zero length string will return true)
  • Arrays (an array with no elements will return true)
  • Structs (a struct with no keys will return true)
  • Query (a query with no rows will return true)

Returns: boolean

Usage

IsEmpty( value )

Arguments

Argument Description
value
(any, required)

The value to check. Can be either a string, array, struct or query object.

Examples

The following statements all evaluate to true:

// Strings
IsEmpty( '' ) == true;
IsEmpty( ' ' ) == false;
IsEmpty( '0' ) == false;

// arrays
IsEmpty( [] ) == true;
IsEmpty( [ 1, 2, 3 ] ) == false;

// structs
IsEmpty( {} ) == true;
IsEmpty( { key="value" } ) == false;

// queries
IsEmpty( QueryNew( 'column' ) ) == true;
IsEmpty( QueryNew( 'column', 'varchar', [ [ 'value' ] ] ) ) == false;

// numerics (always non-empty)
IsEmpty( 0 ) == false;
IsEmpty( 1 ) == false;

// booleans (always non-empty)
IsEmpty( false ) == false;
IsEmpty( true ) == false;

Warning

Prior to Lucee 4.5.1.016, IsEmpty( 0 ) and IsEmpty( false ) both returned true.

See also