CreateObject? IsDefined or IsObject?

myobj = CreateObject( "java", "lakjdalsjd" );

How should I test to see if it exists? Should I be using IsDefined("myobj" )? is that the preferred way to do it? Or should I be using IsObject( value ) or something else?

Thanks,

The createObject() method will never return null, so in your example above there is no need to check for existence. isObject() is more of a validation function that tests the type of a variable just like isArray(), isStruct(), isDate(), or isSimpleValue(). isDefined() will test whether a variable exists, but I would typically structKeyExists() on the scope I expect it to be in, or isNull().

3 Likes