IsInstanceOf

Determines whether an object is an instance of a BoxLang interface or component, or of a Java class.

Method Signature

IsInstanceOf(object=[any], typename=[string])

Arguments

Argument
Type
Required
Description
Default

object

any

true

The CFC instance or Java object that you are testing

typename

string

true

The name of the interface, component, or Java class of which the object might be an instance

Examples

Check if Date is instance of java.util.Date

Dates in BL are instances of the java class: java.util.Date

Run Example

isInstanceOf( now(), "java.util.Date" );

Result: false

Additional Examples

Run Example

writeDump( isInstanceOf( {}, "java.util.Map" ) ); // true
writeDump( isInstanceOf( "Boxlang", "java.util.Map" ) ); // false
writeDump( isInstanceOf( "Boxlang", "java.lang.String" ) );
 // true

Last updated

Was this helpful?